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) {
|
||||
init();
|
||||
type = type_;
|
||||
open(mode);
|
||||
//stream.setDevice(this);
|
||||
parse();
|
||||
if (!path.isEmpty()) {
|
||||
open(mode);
|
||||
//stream.setDevice(this);
|
||||
parse();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QPIConfig::QPIConfig(const QString & path, QIODevice::OpenMode mode): QFile(path) {
|
||||
init();
|
||||
type = Config;
|
||||
open(mode);
|
||||
//stream.setDevice(this);
|
||||
parse();
|
||||
if (!path.isEmpty()) {
|
||||
open(mode);
|
||||
//stream.setDevice(this);
|
||||
parse();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QPIConfig::QPIConfig(const QString & path, QPIConfig::FileType type_): QFile(path) {
|
||||
init();
|
||||
type = type_;
|
||||
open(QIODevice::ReadWrite);
|
||||
//stream.setDevice(this);
|
||||
parse();
|
||||
if (!path.isEmpty()) {
|
||||
open(QIODevice::ReadWrite);
|
||||
//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) {
|
||||
QStringList tree = vname.split(delim);
|
||||
Entry * ce = &root;
|
||||
@@ -740,6 +753,8 @@ void QPIConfig::parse(QString content) {
|
||||
stream.seek(0);
|
||||
other.clear();
|
||||
lines = centry = 0;
|
||||
if (!codec.isEmpty())
|
||||
stream.setCodec(codec.toLatin1().data());
|
||||
while (!stream.atEnd()) {
|
||||
other.push_back(QString());
|
||||
src = str = parseLine(stream.readLine());
|
||||
@@ -749,7 +764,6 @@ void QPIConfig::parse(QString content) {
|
||||
if (!prefix.isEmpty())
|
||||
prefix += delim;
|
||||
}
|
||||
//cout << str << endl;
|
||||
tab = str.left(str.indexOf(str.trimmed().left(1)));
|
||||
str = str.trimmed();
|
||||
all = str;
|
||||
|
||||
@@ -66,6 +66,8 @@ public:
|
||||
void setFile(const QString & path, QIODevice::OpenMode mode = QIODevice::ReadWrite);
|
||||
void setString(QString * str);
|
||||
|
||||
void setCodec(const char * codecName);
|
||||
|
||||
class Entry;
|
||||
|
||||
class Branch: public QVector<Entry * > {
|
||||
@@ -102,7 +104,7 @@ public:
|
||||
friend class QPIConfigWidget;
|
||||
friend class ConfigValueWidget;
|
||||
public:
|
||||
Entry() {_parent = 0; _line = -1;}
|
||||
Entry() {_parent = 0; _line = -1;}
|
||||
|
||||
Entry * parent() const {return _parent;}
|
||||
int childCount() {return _children.size();}
|
||||
@@ -269,7 +271,7 @@ private:
|
||||
Branch all_includes;
|
||||
QFile * dev;
|
||||
QStringList incdirs;
|
||||
QString delim, * buffer;
|
||||
QString delim, * buffer, codec;
|
||||
Entry root, empty;
|
||||
uint lines;
|
||||
QStringList other;
|
||||
|
||||
Reference in New Issue
Block a user