9.10.2011 - stable backup commit

This commit is contained in:
peri4
2011-10-09 22:23:52 +04:00
parent 29190ea465
commit 39ec9cac5c
39 changed files with 1170 additions and 512 deletions

View File

@@ -42,15 +42,15 @@ public:
Branch getLeaves();
Branch getBranches();
Branch & filter(const PIString & f);
inline bool isEntryExists(const PIString & name) const {piForeachCA (i, *this) if (entryExists(i, name)) return true; return false;}
inline bool isEntryExists(const PIString & name) const {piForeachC (Entry * i, *this) if (entryExists(i, name)) return true; return false;}
inline int indexOf(const Entry * e) {for (int i = 0; i < size_s(); ++i) if (at(i) == e) return i; return -1;}
inline void clear() {piForeachA (i, *this) delete i; PIVector<Entry * >::clear();}
inline void clear() {piForeach (Entry * i, *this) delete i; PIVector<Entry * >::clear();}
private:
bool entryExists(const Entry * e, const PIString & name) const;
inline void allLeaves(Branch & b, Entry * e) {piForeachCA (i, e->_children) {if (i->isLeaf()) b << i; else allLeaves(b, i);}}
inline void coutt(std::ostream & s, const PIString & p) const {piForeachCA (i, *this) i->coutt(s, p);}
inline void allLeaves(Branch & b, Entry * e) {piForeach (Entry * i, e->_children) {if (i->isLeaf()) b << i; else allLeaves(b, i);}}
inline void coutt(std::ostream & s, const PIString & p) const {piForeachC (Entry * i, *this) i->coutt(s, p);}
static Entry _empty;
PIString delim;
@@ -67,14 +67,15 @@ public:
inline int childCount() {return _children.size_s();}
inline Branch & children() {_children.delim = delim; return _children;}
inline Entry * child(const int index) const {return _children[index];}
inline Entry * findChild(const PIString & name) {piForeachCA (i, _children) if (i->_name == name) return i; return 0;}
inline const Entry * findChild(const PIString & name) const {piForeachCA (i, _children) if (i->_name == name) return i; return 0;}
inline Entry * findChild(const PIString & name) {piForeach (Entry * i, _children) if (i->_name == name) return i; return 0;}
inline const Entry * findChild(const PIString & name) const {piForeachC (Entry * i, _children) if (i->_name == name) return i; return 0;}
inline bool isLeaf() const {return _children.isEmpty();}
inline const PIString & name() const {return _name;}
inline const PIString & value() const {return _value;}
inline const PIString & type() const {return _type;}
inline const PIString & comment() const {return _comment;}
inline const PIString & fullName() const {return _full_name;}
inline Entry & setName(const PIString & value) {_name = value; return *this;}
inline Entry & setType(const PIString & value) {_type = value; return *this;}
@@ -120,7 +121,7 @@ public:
bool entryExists(const Entry * e, const PIString & name) const;
inline void buildLine() {_all = _tab + _full_name + " = " + _value + " #" + _type + " " + _comment;}
inline void clear() {_children.clear(); _name = _value = _type = _comment = _all = PIString(); _line = 0; _parent = 0;}
inline void coutt(std::ostream & s, const PIString & p) const {PIString nl = p + " "; if (!_value.isEmpty()) s << p << _name << " = " << _value << endl; else cout << p << _name << endl; piForeachCA (i, _children) i->coutt(s, nl);}
inline void coutt(std::ostream & s, const PIString & p) const {PIString nl = p + " "; if (!_value.isEmpty()) s << p << _name << " = " << _value << endl; else cout << p << _name << endl; piForeachC (Entry * i, _children) i->coutt(s, nl);}
static Entry _empty;
Entry * _parent;
@@ -159,7 +160,7 @@ public:
inline int entriesCount() const {return childCount(&root);}
inline bool isEntryExists(const PIString & name) const {return entryExists(&root, name);}
inline Branch allTree() {Branch b; piForeachCA (i, root._children) b << i; return b;}
inline Branch allTree() {Branch b; piForeach (Entry * i, root._children) b << i; return b;}
inline Branch allLeaves() {Branch b; allLeaves(b, &root); std::sort(b.begin(), b.end(), Entry::compare); return b;}
int entryIndex(const PIString & name);
@@ -184,11 +185,11 @@ public:
void setDelimiter(const PIString & d) {delim = d; setEntryDelim(&root, d); readAll();}
private:
int childCount(const Entry * e) const {int c = 0; piForeachCA (i, e->_children) c += childCount(i); c += e->_children.size_s(); return c;}
int childCount(const Entry * e) const {int c = 0; piForeachC (Entry * i, e->_children) c += childCount(i); c += e->_children.size_s(); return c;}
bool entryExists(const Entry * e, const PIString & name) const;
void buildFullNames(Entry * e) {piForeachCA (i, e->_children) {if (e != &root) i->_full_name = e->_full_name + delim + i->_name; else i->_full_name = i->_name; buildFullNames(i);}}
void allLeaves(Branch & b, Entry * e) {piForeachCA (i, e->_children) {if ((!i->_value.isEmpty() && !i->isLeaf()) || i->isLeaf()) b << i; allLeaves(b, i);}}
void setEntryDelim(Entry * e, const PIString & d) {piForeachCA (i, e->_children) setEntryDelim(i, d); e->delim = d;}
void buildFullNames(Entry * e) {piForeach (Entry * i, e->_children) {if (e != &root) i->_full_name = e->_full_name + delim + i->_name; else i->_full_name = i->_name; buildFullNames(i);}}
void allLeaves(Branch & b, Entry * e) {piForeach (Entry * i, e->_children) {if ((!i->_value.isEmpty() && !i->isLeaf()) || i->isLeaf()) b << i; allLeaves(b, i);}}
void setEntryDelim(Entry * e, const PIString & d) {piForeach (Entry * i, e->_children) setEntryDelim(i, d); e->delim = d;}
inline Entry & entryByIndex(const int index) {Branch b = allLeaves(); if (index < 0 || index >= b.size_s()) return empty; return *(b[index]);}
void removeEntry(Branch & b, Entry * e);
void parse();