2 #ifndef _MADARA_EXPRESSION_VARIABLEEXPANDER_H_
3 #define _MADARA_EXPRESSION_VARIABLEEXPANDER_H_
5 #ifndef _MADARA_NO_KARL_
35 std::vector<std::string>& splitters, std::vector<std::string>& tokens,
36 std::vector<std::string>& pivot_list)
43 if (key.find(
"{") != key.npos)
46 "%s: Variable %s requires variable expansion.\n",
47 print_prefix.c_str(), key.c_str());
49 key_expansion_necessary =
true;
50 splitters.push_back(
"{");
51 splitters.push_back(
"}");
55 if (pivot_list.size() % 2 != 0)
57 std::stringstream buffer;
58 buffer << print_prefix;
59 buffer <<
": KARL COMPILE ERROR: matching braces not found in ";
60 buffer << key <<
"\n";
68 std::vector<std::string>::const_iterator pivot = pivot_list.begin();
69 unsigned int num_opens = 0;
70 unsigned int num_closes = 0;
72 for (; pivot != pivot_list.end(); ++pivot)
78 else if (*pivot ==
"}")
84 if (num_opens > num_closes)
86 std::stringstream buffer;
87 buffer << print_prefix;
88 buffer <<
": KARL COMPILE ERROR: more opening braces than closing in ";
89 buffer << key <<
"\n";
95 else if (num_closes > num_opens)
97 std::stringstream buffer;
98 buffer << print_prefix;
99 buffer <<
": KARL COMPILE ERROR: more closing braces than opening in ";
100 buffer << key <<
"\n";
#define madara_logger_ptr_log(loggering, level,...)
Fast version of the madara::logger::log method for Logger pointers.
An exception for unrecoverable KaRL compilation issues.
madara::knowledge::VariableReference expand(const std::string &key, const std::string &print_prefix, madara::knowledge::ThreadSafeContext &context, madara::logger::Logger *cur_logger, bool &key_expansion_necessary, std::vector< std::string > &splitters, std::vector< std::string > &tokens, std::vector< std::string > &pivot_list)
Expands a key into either a VariableReference or tokens.
This class stores variables and their values for use by any entity needing state information in a thr...
VariableReference get_ref(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Atomically returns a reference to the variable.
Optimized reference to a variable within the knowledge base.
A multi-threaded logger for logging to one or more destinations.
void tokenizer(const std::string &input, const ::std::vector< std::string > &splitters, ::std::vector< std::string > &tokens, ::std::vector< std::string > &pivots)
Split a string into tokens.
Copyright(c) 2020 Galois.