36 #ifndef _WOLFRAME_PROPERTY_TREE_HPP_INCLUDED
37 #define _WOLFRAME_PROPERTY_TREE_HPP_INCLUDED
45 #include <boost/property_tree/ptree.hpp>
46 #include <boost/shared_ptr.hpp>
47 #include <boost/algorithm/string.hpp>
81 std::string
string()
const {
return *
this;}
103 explicit Node(
const boost::property_tree::ptree& pt);
125 const Node&
getChild(
const std::string& nodename)
const;
129 std::vector<const Node*>
getChildren(
const std::string& nodename)
const;
146 typedef std::vector<Assignment>::iterator
iterator;
149 std::vector<Assignment>::const_iterator
end()
const {
return m_subnodes.end();}
174 PropertyTree(
const boost::property_tree::ptree& o,
const std::string& filename_)
PropertyTree(const boost::property_tree::ptree &o, const std::string &filename_)
Constructor.
Definition: propertyTree.hpp:174
Defines a data structure to hold positional info in a source file for error messsages etc...
std::vector< Assignment > m_subnodes
child node list
Definition: propertyTree.hpp:161
PropertyTree()
Constructor.
Definition: propertyTree.hpp:168
const Node & root() const
Get the root node of the tree.
Definition: propertyTree.hpp:185
std::pair< std::string, Node > Assignment
Definition: propertyTree.hpp:89
void setValue(const std::string &val)
Set the value of the node.
Definition: propertyTree.hpp:109
Property tree node.
Definition: propertyTree.hpp:86
Value(const std::string &token, Position position_=Position())
Constructor.
Definition: propertyTree.hpp:74
Position m_position
position of node definition start in source
Definition: propertyTree.hpp:162
void recursiveSetFileName(const FileName &filename)
Set the file name of the definition of this node in source recursively for all sub nodes where the fi...
Definition: propertyTree.hpp:115
Position position
position of node definition start in source
Definition: propertyTree.hpp:80
const std::string & data() const
Definition: propertyTree.hpp:142
Property tree node value.
Definition: propertyTree.hpp:67
Hierarchical data structure for representing configuration data trees.
Definition: propertyTree.hpp:57
std::vector< const Node * > getChildren(const std::string &nodename) const
Get a all children nodes with the a certain name.
void setPosition(const Position &p)
Set the position of the node in source.
Definition: propertyTree.hpp:112
std::string tostring(const utils::PrintFormat *pformat=0) const
Get the property sub tree of this node as string.
Value()
Default constructor.
Definition: propertyTree.hpp:72
Node m_root
root node of the property tree
Definition: propertyTree.hpp:202
const Position & position() const
Definition: propertyTree.hpp:143
std::string string() const
cast to string (cast operator leads to problems here, so we define it with an explicit method call) ...
Definition: propertyTree.hpp:81
Value(const Value &o)
Copy constructor.
Definition: propertyTree.hpp:77
Node::const_iterator begin() const
Get the start iterator of the root node children.
Definition: propertyTree.hpp:187
PropertyTree(const Node &root_)
Constructor.
Definition: propertyTree.hpp:181
std::vector< Assignment >::const_iterator end() const
Definition: propertyTree.hpp:149
std::vector< Assignment >::const_iterator begin() const
Definition: propertyTree.hpp:148
std::vector< Assignment >::iterator iterator
Definition: propertyTree.hpp:146
Source line info with filename reference for error messages.
Definition: fileLineInfo.hpp:47
utils::FileLineInfo::FileName FileName
Filename of the source where the node was defined.
Definition: propertyTree.hpp:63
Node(const Position &pos=Position())
Constructor.
Definition: propertyTree.hpp:93
void add_child(const std::string &name_, const Node &node_)
Add child reference.
Definition: propertyTree.hpp:136
Node getChildrenJoined(const std::string &nodename) const
Get a all children nodes with the a certain name joined to one node.
std::string tostring(const utils::PrintFormat *pformat=0) const
Get this property tree as string.
Definition: propertyTree.hpp:196
std::vector< Assignment >::const_iterator const_iterator
Definition: propertyTree.hpp:145
Node::iterator begin()
Get the start iterator of the root node children.
Definition: propertyTree.hpp:191
std::vector< Assignment >::iterator end()
Definition: propertyTree.hpp:151
utils::FileLineInfo Position
Position in the source file where the node was defined.
Definition: propertyTree.hpp:61
Node::const_iterator end() const
Get the end iterator of the root node children.
Definition: propertyTree.hpp:189
boost::shared_ptr< char > FileName
Definition: fileLineInfo.hpp:51
Node(const std::string &val, const Position &pos=Position())
Constructor.
Definition: propertyTree.hpp:99
Node::iterator end()
Get the end iterator of the root node children.
Definition: propertyTree.hpp:193
bool empty() const
Definition: propertyTree.hpp:141
static void print(std::ostringstream &out, const Node &nd, int indent, const utils::PrintFormat *pformat=0)
Print the property sub tree of this node to a stream.
PropertyTree(const PropertyTree &o)
Copy constructor.
Definition: propertyTree.hpp:170
std::string m_data
node value
Definition: propertyTree.hpp:163
const Node & getChild(const std::string &nodename) const
Get a child node by name.
std::vector< Assignment >::iterator begin()
Definition: propertyTree.hpp:150
static FileName getFileName(const std::string &name)