git-svn-id: svn://db.shs.com.ru/libs@588 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -241,27 +241,33 @@ bool QPIConfig::Entry::entryExists(const Entry * e, const QString & name) const
|
|||||||
QPIConfig::QPIConfig(const QString & path, QIODevice::OpenMode mode, QPIConfig::FileType type_): QFile(path) {
|
QPIConfig::QPIConfig(const QString & path, QIODevice::OpenMode mode, QPIConfig::FileType type_): QFile(path) {
|
||||||
init();
|
init();
|
||||||
type = type_;
|
type = type_;
|
||||||
open(mode);
|
if (!path.isEmpty()) {
|
||||||
//stream.setDevice(this);
|
open(mode);
|
||||||
parse();
|
//stream.setDevice(this);
|
||||||
|
parse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QPIConfig::QPIConfig(const QString & path, QIODevice::OpenMode mode): QFile(path) {
|
QPIConfig::QPIConfig(const QString & path, QIODevice::OpenMode mode): QFile(path) {
|
||||||
init();
|
init();
|
||||||
type = Config;
|
type = Config;
|
||||||
open(mode);
|
if (!path.isEmpty()) {
|
||||||
//stream.setDevice(this);
|
open(mode);
|
||||||
parse();
|
//stream.setDevice(this);
|
||||||
|
parse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QPIConfig::QPIConfig(const QString & path, QPIConfig::FileType type_): QFile(path) {
|
QPIConfig::QPIConfig(const QString & path, QPIConfig::FileType type_): QFile(path) {
|
||||||
init();
|
init();
|
||||||
type = type_;
|
type = type_;
|
||||||
open(QIODevice::ReadWrite);
|
if (!path.isEmpty()) {
|
||||||
//stream.setDevice(this);
|
open(QIODevice::ReadWrite);
|
||||||
parse();
|
//stream.setDevice(this);
|
||||||
|
parse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -340,6 +346,13 @@ void QPIConfig::setString(QString * str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QPIConfig::setCodec(const char * codecName) {
|
||||||
|
codec = codecName;
|
||||||
|
stream.setCodec(codecName);
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QPIConfig::Entry & QPIConfig::getValue(const QString & vname, const QString & def, bool * exist) {
|
QPIConfig::Entry & QPIConfig::getValue(const QString & vname, const QString & def, bool * exist) {
|
||||||
QStringList tree = vname.split(delim);
|
QStringList tree = vname.split(delim);
|
||||||
Entry * ce = &root;
|
Entry * ce = &root;
|
||||||
@@ -740,6 +753,8 @@ void QPIConfig::parse(QString content) {
|
|||||||
stream.seek(0);
|
stream.seek(0);
|
||||||
other.clear();
|
other.clear();
|
||||||
lines = centry = 0;
|
lines = centry = 0;
|
||||||
|
if (!codec.isEmpty())
|
||||||
|
stream.setCodec(codec.toLatin1().data());
|
||||||
while (!stream.atEnd()) {
|
while (!stream.atEnd()) {
|
||||||
other.push_back(QString());
|
other.push_back(QString());
|
||||||
src = str = parseLine(stream.readLine());
|
src = str = parseLine(stream.readLine());
|
||||||
@@ -749,7 +764,6 @@ void QPIConfig::parse(QString content) {
|
|||||||
if (!prefix.isEmpty())
|
if (!prefix.isEmpty())
|
||||||
prefix += delim;
|
prefix += delim;
|
||||||
}
|
}
|
||||||
//cout << str << endl;
|
|
||||||
tab = str.left(str.indexOf(str.trimmed().left(1)));
|
tab = str.left(str.indexOf(str.trimmed().left(1)));
|
||||||
str = str.trimmed();
|
str = str.trimmed();
|
||||||
all = str;
|
all = str;
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ public:
|
|||||||
void setFile(const QString & path, QIODevice::OpenMode mode = QIODevice::ReadWrite);
|
void setFile(const QString & path, QIODevice::OpenMode mode = QIODevice::ReadWrite);
|
||||||
void setString(QString * str);
|
void setString(QString * str);
|
||||||
|
|
||||||
|
void setCodec(const char * codecName);
|
||||||
|
|
||||||
class Entry;
|
class Entry;
|
||||||
|
|
||||||
class Branch: public QVector<Entry * > {
|
class Branch: public QVector<Entry * > {
|
||||||
@@ -102,7 +104,7 @@ public:
|
|||||||
friend class QPIConfigWidget;
|
friend class QPIConfigWidget;
|
||||||
friend class ConfigValueWidget;
|
friend class ConfigValueWidget;
|
||||||
public:
|
public:
|
||||||
Entry() {_parent = 0; _line = -1;}
|
Entry() {_parent = 0; _line = -1;}
|
||||||
|
|
||||||
Entry * parent() const {return _parent;}
|
Entry * parent() const {return _parent;}
|
||||||
int childCount() {return _children.size();}
|
int childCount() {return _children.size();}
|
||||||
@@ -269,7 +271,7 @@ private:
|
|||||||
Branch all_includes;
|
Branch all_includes;
|
||||||
QFile * dev;
|
QFile * dev;
|
||||||
QStringList incdirs;
|
QStringList incdirs;
|
||||||
QString delim, * buffer;
|
QString delim, * buffer, codec;
|
||||||
Entry root, empty;
|
Entry root, empty;
|
||||||
uint lines;
|
uint lines;
|
||||||
QStringList other;
|
QStringList other;
|
||||||
|
|||||||
Reference in New Issue
Block a user