15.10.2012 - version 0.2.0 - PIIODevice - base of file, ethernet, serial and packets extractor. PIEthernet now support also TCP (client and server). PIConsole now can align labels in each column individually.
This commit is contained in:
16
piconfig.cpp
Normal file → Executable file
16
piconfig.cpp
Normal file → Executable file
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Config parser
|
||||
Copyright (C) 2011 Ivan Pelipenko peri4ko@gmail.com
|
||||
Copyright (C) 2012 Ivan Pelipenko peri4ko@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -171,13 +171,13 @@ bool PIConfig::Entry::entryExists(const Entry * e, const PIString & name) const
|
||||
}
|
||||
|
||||
|
||||
PIConfig::PIConfig(const PIString & path, PIFlags<Mode> mode): PIFile(path, mode) {
|
||||
PIConfig::PIConfig(const PIString & path, PIIODevice::DeviceMode mode): PIFile(path, mode) {
|
||||
delim = ".";
|
||||
root.delim = delim;
|
||||
empty.delim = delim;
|
||||
empty._parent = 0;
|
||||
if (!isOpened() && (mode[Write] || mode[New]))
|
||||
open(path, Read | Write | New);
|
||||
if (!isOpened())
|
||||
open(path, mode);
|
||||
parse();
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ void PIConfig::addEntry(const PIString & name, const PIString & value, const PIS
|
||||
} else entry = te;
|
||||
}
|
||||
PIConfig::Branch ch = entry->_children;
|
||||
std::sort(ch.begin(), ch.end(), PIConfig::Entry::compare);
|
||||
ch.sort(PIConfig::Entry::compare);
|
||||
te = (entry->isLeaf() ? 0 : ch.back());
|
||||
ce = new Entry();
|
||||
ce->delim = delim;
|
||||
@@ -249,7 +249,7 @@ void PIConfig::addEntry(const PIString & name, const PIString & value, const PIS
|
||||
if (toRoot) ce->_line = other.size_s() - 1;
|
||||
else {
|
||||
ch = entry->_parent->_children;
|
||||
std::sort(ch.begin(), ch.end(), PIConfig::Entry::compare);
|
||||
ch.sort(PIConfig::Entry::compare);
|
||||
ce->_line = ch.back()->_line + 1;
|
||||
}
|
||||
}
|
||||
@@ -369,8 +369,8 @@ void PIConfig::removeEntry(Branch & b, PIConfig::Entry * e) {
|
||||
if (b[i] == e) found = true;
|
||||
}
|
||||
if (!leaf) return;
|
||||
e->_parent->_children.remove(e);
|
||||
b.remove(e);
|
||||
e->_parent->_children.removeOne(e);
|
||||
b.removeOne(e);
|
||||
delete e;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user