mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 06:14:59 +00:00
Each plugin now follows the standardized structure:
- category/plugin_name/plugin_name.{ext} - Implementation
- category/plugin_name/package.json - Plugin metadata
- category/package.json - Category manifest with "plugins" array
Languages restructured:
- Go: 31 plugins across 7 categories (math, string, logic, list, dict, var, convert)
- Rust: 55 plugins as individual crates in Cargo workspace
- C++: 34 header-only plugins with complete coverage
- Mojo: 11 plugins across 3 categories (math, string, list)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
43 lines
1002 B
C++
43 lines
1002 B
C++
#pragma once
|
|
/**
|
|
* Workflow plugin: trim whitespace from string
|
|
*/
|
|
|
|
#include "../../plugin.hpp"
|
|
#include <algorithm>
|
|
#include <cctype>
|
|
|
|
namespace metabuilder::workflow::string {
|
|
|
|
inline PluginResult trim(Runtime&, const json& inputs) {
|
|
auto text = inputs.value("text", std::string{});
|
|
auto mode = inputs.value("mode", std::string{"both"});
|
|
|
|
auto ltrim = [](std::string& s) {
|
|
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) {
|
|
return !std::isspace(ch);
|
|
}));
|
|
};
|
|
|
|
auto rtrim = [](std::string& s) {
|
|
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) {
|
|
return !std::isspace(ch);
|
|
}).base(), s.end());
|
|
};
|
|
|
|
std::string result = text;
|
|
|
|
if (mode == "start") {
|
|
ltrim(result);
|
|
} else if (mode == "end") {
|
|
rtrim(result);
|
|
} else {
|
|
ltrim(result);
|
|
rtrim(result);
|
|
}
|
|
|
|
return {{"result", result}};
|
|
}
|
|
|
|
} // namespace metabuilder::workflow::string
|