23 #ifndef NDN_BOOST_INFO_PARSER_HPP
24 #define NDN_BOOST_INFO_PARSER_HPP
30 #include <ndn-cpp/common.hpp>
50 : value_(value), parent_(parent), lastChild_(0)
61 (
const std::string& treeName,
62 const ptr_lib::shared_ptr<BoostInfoTree>& newTree);
71 createSubtree(
const std::string& treeName,
const std::string& value =
"");
78 std::vector<const BoostInfoTree*>
90 std::vector<const BoostInfoTree*> list = (*this)[key];
92 return &list[0]->value_;
98 getValue()
const {
return value_; }
101 getParent() {
return parent_; }
104 getLastChild() {
return lastChild_; }
107 prettyPrint(
int indentLevel = 1)
const;
116 std::vector<ptr_lib::shared_ptr<BoostInfoTree> >*
117 find(
const std::string& treeName);
119 static std::vector<std::string>
120 split(
const std::string &input,
char separator);
123 std::vector<std::pair<std::string, std::vector<ptr_lib::shared_ptr<BoostInfoTree> > > > subtrees_;
125 BoostInfoTree* parent_;
126 BoostInfoTree* lastChild_;
130 operator << (std::ostream& os,
const BoostInfoTree& tree)
132 os << tree.prettyPrint();
154 read(
const std::string& fileName);
164 read(
const std::string& input,
const std::string& inputName);
173 write(
const std::string& fileName)
const;
193 shlex_split(
const std::string& s, std::vector<std::string>& result);
210 ptr_lib::shared_ptr<BoostInfoTree> root_;
const BoostInfoTree & createSubtree(const std::string &treeName, const std::string &value="")
Create a new BoostInfo and insert it as a sub-tree with the given name.
Definition: boost-info-parser.cpp:53
void addSubtree(const std::string &treeName, const ptr_lib::shared_ptr< BoostInfoTree > &newTree)
Insert a BoostInfoTree as a sub-tree with the given name.
Definition: boost-info-parser.cpp:37
void write(const std::string &fileName) const
Write the root tree of this BoostInfoParser as file in Boost's INFO format.
Definition: boost-info-parser.cpp:188
BoostInfoTree is provided for compatibility with the Boost INFO property list format used in ndn-cxx...
Definition: boost-info-parser.hpp:46
const BoostInfoTree & getRoot() const
Get the root tree of this parser.
Definition: boost-info-parser.hpp:180
const BoostInfoTree & read(const std::string &fileName)
Add the contents of the file to the root BoostInfoTree.
std::vector< const BoostInfoTree * > operator[](const std::string &key) const
Look up using the key and return a list of the subtrees.
Definition: boost-info-parser.cpp:61
A BoostInfoParser reads files in Boost's INFO format and constructs a BoostInfoTree.
Definition: boost-info-parser.hpp:140
const std::string * getFirstValue(const std::string &key) const
Look up using the key and return string value of the first subtree.
Definition: boost-info-parser.hpp:88