2 #ifndef _MADARA_NO_KARL_
36 for (ComponentNodes::iterator i = nodes_.begin(); i != nodes_.end(); ++i)
38 bool arg_can_change =
false;
39 result = (*i)->prune(arg_can_change);
41 if (!arg_can_change &&
dynamic_cast<LeafNode*
>(*i) == 0)
44 *i =
new LeafNode(*(this->logger_), result);
48 if (nodes_.size() == 0 || nodes_.size() > 2)
51 "madara::expression::SystemCallRandInt: "
53 "System call read_file"
54 " requires at least a filename to read, e.g."
55 " #read_file (filename), #read_file (filename, 'text')."
56 " Second argument is to force a file type when the filename"
57 " does not end with .txt, .xml, .jpg, etc. Can be 'text',"
61 "madara::expression::SystemCallRandInt: "
62 "KARL COMPILE ERROR: "
63 "System call read_file"
64 " requires at least a filename to read, e.g."
65 " #read_file (filename), #read_file (filename, 'text')."
66 " Second argument is to force a file type when the filename"
67 " does not end with .txt, .xml, .jpg, etc. Can be 'text',"
82 if (nodes_.size() > 0)
87 uint32_t read_as_type_uint(0);
88 (void)read_as_type_uint;
91 "madara::expression::SystemCallReadFile: "
92 "System call read_file is attempting to open %s.\n",
95 if (nodes_.size() == 2)
100 read_as_type_uint = (uint32_t)read_as_type.
to_integer();
109 else if (type ==
"jpeg")
113 else if (type ==
"xml")
123 "madara::expression::SystemCallReadFile: "
124 "KARL RUNTIME WARNING: System call read_file could not open %s.\n",
131 "madara::expression::SystemCallReadFile: "
132 "KARL COMPILE ERROR:"
133 "System call read_file"
134 " requires at least a filename to read, e.g."
135 " #read_file (filename), #read_file (filename, 'text')."
136 " Second argument is to force a file type when the filename"
137 " does not end with .txt, .xml, .jpg, etc. Can be 'text',"
141 "madara::expression::SystemCallReadFile: "
142 "KARL COMPILE ERROR: "
143 "System call read_file"
144 " requires at least a filename to read, e.g."
145 " #read_file (filename), #read_file (filename, 'text')."
146 " Second argument is to force a file type when the filename"
147 " does not end with .txt, .xml, .jpg, etc. Can be 'text',"
158 visitor.
visit(*
this);
#define madara_logger_ptr_log(loggering, level,...)
Fast version of the madara::logger::log method for Logger pointers.
madara::knowledge::KnowledgeRecord KnowledgeRecord
An exception for unrecoverable KaRL compilation issues.
Defines a node that contains a madara::knowledge::KnowledgeRecord::Integer value.
Interface for a MADARA system call.
virtual ~SystemCallReadFile(void)
Destructor.
virtual void accept(Visitor &visitor) const
Accepts a visitor subclassed from the Visitor class.
SystemCallReadFile(madara::knowledge::ThreadSafeContext &context, const ComponentNodes &nodes)
Constructor.
virtual madara::knowledge::KnowledgeRecord prune(bool &can_change)
Prunes the expression tree of unnecessary nodes.
virtual madara::knowledge::KnowledgeRecord item(void) const
Returns the value of the node.
virtual madara::knowledge::KnowledgeRecord evaluate(const madara::knowledge::KnowledgeUpdateSettings &settings)
Evaluates the expression tree.
Abstract base class for all visitors to all classes that derive from ComponentNode.
virtual void visit(const LeafNode &node)=0
Visit a LeafNode.
This class encapsulates an entry in a KnowledgeBase.
std::string to_string(const std::string &delimiter=", ") const
converts the value to a string.
uint32_t type(void) const
returns the type of the value
Integer to_integer(void) const
converts the value to an integer.
bool is_string_type(void) const
returns true if the record is a string type (STRING, XML, TEXT_FILE)
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
Settings for applying knowledge updates.
This class stores variables and their values for use by any entity needing state information in a thr...
std::deque< ComponentNode * > ComponentNodes
a vector of Component Nodes