40 for(map<string,PersistNode*>::iterator i=
_child.begin(); i!=
_child.end(); ++i)
49 for(map<string,string>::const_iterator i=
_attr.begin();
53 os<<
" "<<i->first<<
"="<<i->second<<
'\n';
58 for(map<string,PersistNode*>::const_iterator i=
_child.begin();
62 i->second->output(os,name+i->first);
93 is.ignore(INT_MAX,
'\n');
100 string::size_type pos =name.find(
'/');
104 if(pos==string::npos)
115 return newchild->
addnode(name.substr(pos+1));
121 string::size_type pos =name.find(
'/');
123 map<string,PersistNode*>::iterator childpos =
_child.find(name.substr(0,pos));
124 if(childpos!=
_child.end())
126 if(pos==string::npos)
128 delete childpos->second;
133 childpos->second->delnode(name.substr(pos+1));
140 string::size_type pos =keyvalue.find(
'=');
141 _attr[keyvalue.substr(0,pos)]=(pos==string::npos?
"":keyvalue.substr(pos+1));
147 sprintf(buf,
"%i",value);
148 _attr[key]=string(buf);
157 map<string,string>::const_iterator pos=
_attr.find(key);
165 map<string,string>::const_iterator pos=
_attr.find(key);
169 return atol(pos->second.c_str());
173 map<string,PersistNode*>::const_iterator pos=
_child.find(key);
void output(ostream &os, string name) const
bool readtoken(istream &is, string &tok)
map< string, PersistNode * > _child
bool hasAttr(const string &key) const
map< string, string > _attr
~PersistNode()
Free node and all its children.
string attrString(const string &key, const string &fallback="") const
void delnode(const string &name)
PersistNode * addnode(const string &name)
bool readnode(istream &is)
long attrLong(const string &key, long fallback=0) const
PersistNode()
Create an empty node.
PersistNode * child(const string &key) const
void addattr(const string &keyvalue)