2 #ifndef _MADARA_NO_KARL_ 42 for (ComponentNodes::iterator i =
nodes_.begin (); i !=
nodes_.end ();
45 bool arg_can_change =
false;
46 result = (*i)->prune (arg_can_change);
48 if (!arg_can_change && dynamic_cast <LeafNode *> (*i) == 0)
58 "madara::expression::SystemCallRandInt: " 60 "System call read_file" 61 " requires at least a filename to read, e.g." 62 " #read_file (filename), #read_file (filename, 'text')." 63 " Second argument is to force a file type when the filename" 64 " does not end with .txt, .xml, .jpg, etc. Can be 'text'," 67 throw KarlException (
"madara::expression::SystemCallRandInt: " 68 "KARL COMPILE ERROR: " 69 "System call read_file" 70 " requires at least a filename to read, e.g." 71 " #read_file (filename), #read_file (filename, 'text')." 72 " Second argument is to force a file type when the filename" 73 " does not end with .txt, .xml, .jpg, etc. Can be 'text'," 93 uint32_t read_as_type_uint (0);
94 (void)read_as_type_uint;
97 "madara::expression::SystemCallReadFile: " 98 "System call read_file is attempting to open %s.\n",
106 read_as_type_uint = (uint32_t) read_as_type.
to_integer ();
115 else if (type ==
"jpeg")
119 else if (type ==
"xml")
129 "madara::expression::SystemCallReadFile: " 130 "KARL RUNTIME WARNING: System call read_file could not open %s.\n",
137 "madara::expression::SystemCallReadFile: " 138 "KARL COMPILE ERROR:" 139 "System call read_file" 140 " requires at least a filename to read, e.g." 141 " #read_file (filename), #read_file (filename, 'text')." 142 " Second argument is to force a file type when the filename" 143 " does not end with .txt, .xml, .jpg, etc. Can be 'text'," 146 throw KarlException (
"madara::expression::SystemCallReadFile: " 147 "KARL COMPILE ERROR: " 148 "System call read_file" 149 " requires at least a filename to read, e.g." 150 " #read_file (filename), #read_file (filename, 'text')." 151 " Second argument is to force a file type when the filename" 152 " does not end with .txt, .xml, .jpg, etc. Can be 'text'," 164 visitor.
visit (*
this);
167 #endif // _MADARA_NO_KARL_ This class encapsulates an entry in a KnowledgeBase.
int32_t type(void) const
returns the size of the value
virtual madara::knowledge::KnowledgeRecord item(void) const
Returns the value of the node.
madara::knowledge::KnowledgeRecord KnowledgeRecord
std::deque< ComponentNode * > ComponentNodes
a vector of Component Nodes
virtual madara::knowledge::KnowledgeRecord prune(bool &can_change)
Prunes the expression tree of unnecessary nodes.
logger::Logger * logger_
handle the context
virtual ~SystemCallReadFile(void)
Destructor.
This class stores variables and their values for use by any entity needing state information in a thr...
Defines a node that contains a madara::knowledge::KnowledgeRecord::Integer value. ...
#define madara_logger_ptr_log(logger, level,...)
Fast version of the madara::logger::log method for Logger pointers.
Abstract base class for all visitors to all classes that derive from ComponentNode.
Integer to_integer(void) const
converts the value to an integer.
An exception for unrecoverable KaRL compilation issues.
Interface for a MADARA system call.
SystemCallReadFile(madara::knowledge::ThreadSafeContext &context, const ComponentNodes &nodes)
Constructor.
Settings for applying knowledge updates.
virtual void visit(const LeafNode &node)=0
Visit a LeafNode.
int read_file(const std::string &filename, uint32_t read_as_type=0)
reads a file and sets the type appropriately according to the extension
virtual madara::knowledge::KnowledgeRecord evaluate(const madara::knowledge::KnowledgeUpdateSettings &settings)
Evaluates the expression tree.
virtual void accept(Visitor &visitor) const
Accepts a visitor subclassed from the Visitor class.
bool is_string_type(void) const
returns true if the record is a string type (STRING, XML, TEXT_FILE)
std::string to_string(const std::string &delimiter=", ") const
converts the value to a string.