git-svn-id: svn://db.shs.com.ru/libs@533 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2019-05-20 12:39:42 +00:00
parent f804ec5c83
commit e981dd6081
4 changed files with 31 additions and 6 deletions

View File

@@ -146,3 +146,20 @@ PropertyStorage::Property PropertyStorage::parsePropertyLine(QString l) {
}
return ret;
}
PropertyStorage::Property & PropertyStorage::operator[](const QString & name) {
for (int i = 0; i < props.size(); ++i)
if (props[i].name == name)
return props[i];
addProperty(name, "");
return props.back();
}
const PropertyStorage::Property PropertyStorage::operator[](const QString & name) const {
for (int i = 0; i < props.size(); ++i)
if (props[i].name == name)
return props[i];
return Property();
}

View File

@@ -17,6 +17,11 @@ public:
struct Property {
Property(const QString & n = QString(), const QString & c = QString(), const QVariant & v = QVariant(), int f = 0):
name(n), comment(c), value(v), flags(f) {}
bool toBool() const {return value.toBool();}
int toInt() const {return value.toInt();}
float toFloat() const {return value.toFloat();}
double toDouble() const {return value.toDouble();}
QString toString() const {return value.toString();}
QString name;
QString comment;
QVariant value;
@@ -77,7 +82,9 @@ public:
PropertyStorage & operator <<(const PropertyStorage & p) {props << p.props; return *this;}
Property & operator[](int i) {return props[i];}
const Property & operator[](int i) const {return props[i];}
Property & operator[](const QString & name);
const Property operator[](const QString & name) const;
static Property parsePropertyLine(QString l);
protected: