teinifile.h

00001 /****************************************************************************
00002 ** $Id: teinifile.h,v 1.9 2006/06/27 12:08:20 red75 Exp $
00003 **
00004 ** Trade equipment common portable library project
00005 **
00006 ** Copyright (C) 1999-2006 Leader InfoTech.  All rights reserved.
00007 **
00008 ** This file is part of the Library of the Ananas
00009 ** automation accounting system.
00010 **
00011 ** This file may be distributed and/or modified under the terms of the
00012 ** GNU General Public License version 2 as published by the Free Software
00013 ** Foundation and appearing in the file LICENSE.GPL included in the
00014 ** packaging of this file.
00015 **
00016 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00017 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00018 **
00019 ** See http://www.leaderit.ru/ or email sales@leaderit.ru
00020 **
00021 ** Contact org@leaderit.ru if any conditions of this licensing are
00022 ** not clear to you.
00023 **
00024 **********************************************************************/
00025 
00026 // TEIniFile 1.1
00027 //
00028 // Supports storing/reading parameters in text configuration files (like .ini)
00029 //
00030 // (c) Racheengel 2004-2005
00031 #ifndef TEINIFILE_H
00032 #define TEINIFILE_H
00033 
00034 #include <qvariant.h>
00035 #include <qwidget.h>
00036 #include <qfile.h>
00037 #include <qstring.h>
00038 #include <qstringlist.h>
00039 #include <qtextstream.h>
00040 #include <qmap.h>
00041 #include <qcolor.h>
00042 #include <qrect.h>
00043 #include "teglobal.h"
00044 
00045 typedef QMap<QString, QString> type_ValueList;
00046 typedef QMapIterator<QString, QString> type_ValueListIterator;
00047 
00048 #include "templexports.h"
00049 
00050 class LIB_EXPORT TEIniFile
00051 {
00052 public:
00053         TEIniFile(const QString &name = QString::null);
00054         ~TEIniFile();
00055 
00056         void    setFileName(const QString &name);
00057         bool    openWrite();
00058         bool    openRead();
00059         void    close();
00060 
00061         void    writeBreak();
00062         void    writeSection(const QString &section);
00063         void    writeComment(const QString &comment);
00064         void    writeString(const QString &name, const QString &value);
00065         void    writeData(const QString &name, const QString &value);
00066         void    writeNumber(const QString &name, const int value, const int base = 10);
00067         void    writeStringList(const QString &name, const QStringList &value);
00068         void    writeDataList(const QString &name, const QStringList &value);
00069         void    writeBool(const QString &name, const bool value);
00070         void    writeColor(const QString &name, const QColor& color);
00071         void    writeRect(const QString &name, const QRect& rect);
00072 
00073         bool    sectionExists(const QString &section)
00074                         { return SectionList.contains(section); }
00075         bool    useSection(const QString &section);
00076         const QString&  readString(const QString &name, const QString &def = QString::null);
00077         int             readNumber(const QString &name, const int def = 0, const int base = 10);
00078         bool    readBool(const QString &name, const bool def = false);
00079         const QColor&   readColor(const QString &name, const QColor& def = QColor());
00080         const QRect&    readRect(const QString &name, const QRect& def = QRect());
00081 
00082         void    setString(const QString &name, const QString &value);
00083         void    setData(const QString &name, const QString &value);
00084         void    setNumber(const QString &name, const int value, const int base = 10);
00085         void    setStringList(const QString &name, const QStringList &value);
00086         void    setDataList(const QString &name, const QStringList &value);
00087         void    setBool(const QString &name, const bool value);
00088         void    setColor(const QString &name, const QColor& color);
00089         void    setRect(const QString &name, const QRect& rect);
00090 
00092   void deleteName(const QString &name);
00093 
00094   bool isNameExists(const QString &name);
00095   // These functions return true if readXXX function was called with the same /name/ value already.
00096   bool getString(const QString & name, QString & value);
00097 //  bool getData(const QString & name, QString & value);
00098   bool getNumber(const QString & name, int & value, const int base=10);
00099   bool getBool(const QString & name, bool & value);
00100 
00101   bool update();
00102 
00103   QStringList usedValues();
00104 protected:
00105         QTextStream ts;
00106         QFile           f;
00107         QMap<QString, type_ValueList> SectionList;
00108   QMap<QString, type_ValueList> SectionListDef;
00109         QMapIterator<QString, type_ValueList>   mi;
00110   QString m_sCurSection;
00111         bool            m_break;
00112 };
00113 
00114 #endif

Документация по Общая библиотека для работы с торговым оборудованием.. Последние изменения: Sun Jul 2 23:37:24 2006. Создано системой  doxygen 1.4.7