remove operators in QPIConfig::Entry
git-svn-id: svn://db.shs.com.ru/libs@946 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -243,7 +243,6 @@ QPIConfig::QPIConfig(const QString & path, QIODevice::OpenMode mode, QPIConfig::
|
||||
type = type_;
|
||||
if (!path.isEmpty()) {
|
||||
open(mode);
|
||||
//stream.setDevice(this);
|
||||
parse();
|
||||
}
|
||||
}
|
||||
@@ -254,7 +253,6 @@ QPIConfig::QPIConfig(const QString & path, QIODevice::OpenMode mode): QFile(path
|
||||
type = Config;
|
||||
if (!path.isEmpty()) {
|
||||
open(mode);
|
||||
//stream.setDevice(this);
|
||||
parse();
|
||||
}
|
||||
}
|
||||
@@ -265,7 +263,6 @@ QPIConfig::QPIConfig(const QString & path, QPIConfig::FileType type_): QFile(pat
|
||||
type = type_;
|
||||
if (!path.isEmpty()) {
|
||||
open(QIODevice::ReadWrite);
|
||||
//stream.setDevice(this);
|
||||
parse();
|
||||
}
|
||||
}
|
||||
@@ -275,7 +272,6 @@ QPIConfig::QPIConfig(QString * str, QPIConfig::FileType type_) {
|
||||
init();
|
||||
type = type_;
|
||||
buffer = str;
|
||||
//stream.setDevice(this);
|
||||
parse();
|
||||
}
|
||||
|
||||
@@ -565,7 +561,6 @@ void QPIConfig::removeEntry(Branch & b, QPIConfig::Entry * e) {
|
||||
if (e->isLeaf()) other.removeAt(e->_line);
|
||||
if (!e->isLeaf() && !e->_value.isEmpty()) {
|
||||
e->_value.clear();
|
||||
//leaf = false;
|
||||
} else {
|
||||
int cc = e->_children.size();
|
||||
for (int i = 0; i < cc; ++i)
|
||||
@@ -598,14 +593,12 @@ void QPIConfig::writeAll() {
|
||||
buffer->clear();
|
||||
}
|
||||
stream.seek(0);
|
||||
//writeEntry(&root);
|
||||
buildFullNames(&root);
|
||||
Branch b = allLeaves();
|
||||
QString prefix, tprefix;
|
||||
bool isPrefix;
|
||||
int j = 0;
|
||||
for (int i = 0; i < other.size(); ++i) {
|
||||
//cout << j << endl;
|
||||
if (j >= 0 && j < b.size()) {
|
||||
if (b[j]->_line == i) {
|
||||
b[j]->buildLine();
|
||||
@@ -657,12 +650,10 @@ QString QPIConfig::getPrefixFromLine(QString line, bool * exists) {
|
||||
QString QPIConfig::writeAllToString() {
|
||||
QString str;
|
||||
QTextStream s(&str);
|
||||
//writeEntry(&root);
|
||||
buildFullNames(&root);
|
||||
Branch b = allLeaves();
|
||||
int j = 0;
|
||||
for (int i = 0; i < other.size(); ++i) {
|
||||
//cout << j << endl;
|
||||
if (j >= 0 && j < b.size()) {
|
||||
if (b[j]->_line == i) {
|
||||
b[j]->buildLine();
|
||||
@@ -803,7 +794,6 @@ void QPIConfig::parse(QString content) {
|
||||
type = "s";
|
||||
comm = "";
|
||||
}
|
||||
//name = str.left(ind).trimmed();
|
||||
tree = (prefix + str.left(ind).trimmed()).split(delim);
|
||||
if (tree.front() == "include") {
|
||||
name = str.right(str.length() - ind - 1).trimmed();
|
||||
@@ -815,7 +805,6 @@ void QPIConfig::parse(QString content) {
|
||||
includes << iconf << iconf->includes;
|
||||
updateIncludes();
|
||||
}
|
||||
//piCout << "includes" << includes;
|
||||
other.back() = src;
|
||||
} else {
|
||||
name = tree.back();
|
||||
@@ -858,5 +847,4 @@ void QPIConfig::parse(QString content) {
|
||||
}
|
||||
setEntryDelim(&root, delim);
|
||||
buildFullNames(&root);
|
||||
//if (content.isEmpty()) stream.setDevice(this);
|
||||
}
|
||||
|
||||
@@ -88,8 +88,6 @@ public:
|
||||
bool isEntryExists(const QString & name) const {foreach (const Entry * i, *this) if (entryExists(i, name)) return true; return false;}
|
||||
int indexOf(const Entry * e) {for (int i = 0; i < size(); ++i) if (at(i) == e) return i; return -1;}
|
||||
|
||||
//void clear() {foreach (Entry * i, *this) delete i; QVector<Entry * >::clear();}
|
||||
|
||||
private:
|
||||
bool entryExists(const Entry * e, const QString & name) const;
|
||||
void allLeaves(Branch & b, Entry * e) {foreach (Entry * i, e->_children) {if (i->isLeaf()) b << i; else allLeaves(b, i);}}
|
||||
@@ -150,27 +148,26 @@ public:
|
||||
Branch getValues(const QString & vname);
|
||||
|
||||
bool isEntryExists(const QString & name) const {return entryExists(this, name);}
|
||||
const QString & stringValue() const {return _value;}
|
||||
|
||||
operator bool() {return (_value.toLower().trimmed() == "true" || _value.toLower().trimmed() == "yes" || _value.toLower().trimmed() == "on" || _value.toInt() > 0);}
|
||||
operator char() {return (_value.isEmpty() ? 0 : _value[0].toLatin1());}
|
||||
operator short() {return _value.toShort();}
|
||||
operator int() {return QString2int(_value);}
|
||||
operator long() {return QString2int(_value);}
|
||||
operator uchar() {return QString2int(_value);}
|
||||
operator ushort() {return QString2int(_value);}
|
||||
operator uint() {return QString2int(_value);}
|
||||
operator ulong() {return QString2int(_value);}
|
||||
operator float() {return _value.toFloat();}
|
||||
operator double() {return _value.toDouble();}
|
||||
operator QString() {return _value;}
|
||||
operator QStringList() {return _value.split("%|%");}
|
||||
operator QColor() {return QString2QColor(_value);}
|
||||
operator QRect() {return QString2QRect(_value);}
|
||||
operator QRectF() {return QString2QRectF(_value);}
|
||||
operator QPoint() {return QString2QPoint(_value);}
|
||||
operator QPointF() {return QString2QPointF(_value);}
|
||||
operator QByteArray() {return QString2QByteArray(_value);}
|
||||
bool toBool() const {return (_value.toLower().trimmed() == "true" || _value.toLower().trimmed() == "yes" || _value.toLower().trimmed() == "on" || _value.toInt() > 0);}
|
||||
char toChar() const {return (_value.isEmpty() ? 0 : _value[0].toLatin1());}
|
||||
short toShort() const {return _value.toShort();}
|
||||
int toInt() const {return QString2int(_value);}
|
||||
long toLong() const {return QString2int(_value);}
|
||||
uchar toUChar() const {return QString2int(_value);}
|
||||
ushort toUShort() const {return QString2int(_value);}
|
||||
uint toUInt() const {return QString2int(_value);}
|
||||
ulong toULong() const {return QString2int(_value);}
|
||||
float toFloat() const {return _value.toFloat();}
|
||||
double toDouble() const {return _value.toDouble();}
|
||||
QString toString() const {return _value;}
|
||||
QStringList toStringList() const {return _value.split("%|%");}
|
||||
QColor toColor() const {return QString2QColor(_value);}
|
||||
QRect toRect() const {return QString2QRect(_value);}
|
||||
QRectF toRectF() const {return QString2QRectF(_value);}
|
||||
QPoint toPoint() const {return QString2QPoint(_value);}
|
||||
QPointF toPointF() const {return QString2QPointF(_value);}
|
||||
QByteArray toByteArray() const {return QString2QByteArray(_value);}
|
||||
|
||||
private:
|
||||
static bool compare(const QPIConfig::Entry * f, const QPIConfig::Entry * s) {return f->_line < s->_line;}
|
||||
@@ -228,7 +225,7 @@ public:
|
||||
int entryIndex(const QString & name);
|
||||
|
||||
QString getName(uint number) {return entryByIndex(number)._name;}
|
||||
QString getValue(uint number) {return entryByIndex(number)._value;}
|
||||
QString getValueByIndex(uint number) {return entryByIndex(number)._value;}
|
||||
QChar getType(uint number) {return entryByIndex(number)._type[0];}
|
||||
QString getComment(uint number) {return entryByIndex(number)._comment;}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user