X-Git-Url: https://vaikene.ee/gitweb/gitweb.cgi?a=blobdiff_plain;f=src%2Flibs%2FCommon%2Finifile.h;h=5392984dfec8645a9b07bea97a214d699ccbbab9;hb=f01d61fb753b347bbff2ffb7f224650ac3f9d81e;hp=59f6fa0b1ff10fea94cace947395669be72e217c;hpb=09e5758f2e8557be2f23ed7a8a51ca4ef855e9ab;p=evaf diff --git a/src/libs/Common/inifile.h b/src/libs/Common/inifile.h index 59f6fa0..5392984 100644 --- a/src/libs/Common/inifile.h +++ b/src/libs/Common/inifile.h @@ -22,6 +22,10 @@ #include "libcommon.h" +#include +#include +#include + namespace eVaf { namespace Common { namespace Internal { @@ -31,12 +35,25 @@ namespace Internal { /** * Class for reading and writing parameter values in INI files. * - * The IniFile class provides access to parameter values in a standard INI file. Every parameter value is - * identified by a section/key name pair. Key names can be prefixed with 'windows:' or 'linux:' if the - * parameter value is specific for the given platform. This allows entering platform-specific parameter - * values to the INI file. INI files can contain comment lines that start with ';' or '#'. Comments are + * The IniFile class provides access to parameter values in a standard INI file. + * Every parameter value is identified by a section/key name pair. Key names can be prefixed with + * 'windows:' or 'linux:' if the parameter value is specific for the given platform. + * This allows entering platform-specific parameter values to the INI file. + * + * INI files can contain comment lines that start with ';' or '#'. Comments are * preserved when new values are written to the INI file. * + * This is a sample INI %file: + * @code + * [main] + * # The full name of this parameter is 'main/name' + * name = MyApplication + * + * [extensions/about] + * # The full name of this parameter is 'extensions/about/module' + * module = libabout.so + * @endcode + * * Values in INI files are stored as strings and the IniFile class expects them to use specific formats if * the returned value is supposed to be of a different data type. The following list shows the expected format * of different data types: @@ -71,11 +88,6 @@ public: * The isValid() method returns true if the INI file is can be used. Use this * method after creating the object to verify that opening the INI file in the specified * mode succeeded. - * - * If the object is not valid, then: - * @li Writing to the INI file always fails; the internal cache is still updated and reading the parameter returns - * the new value; - * @li Reading from the INI file returns the cached value or the default value if no values with this name are written. */ bool isValid() const; @@ -93,7 +105,7 @@ public: * @return The value from the INI file or an invalid QVariant if failed * * The getValue() method reads a parameter value from the INI file. Parameters are identified by a section and key name pair - * in the format '<section>/<key>'. For example, if the section is called 'general' and the key is called 'log_level', + * in the format '\/\'. For example, if the section is called 'general' and the key is called 'log_level', * then the name of the parameter should be given as 'general/log_level'. Parameter names are case insensitive. * * If the parameter cannot be read because it is not found in the INI file or the INI file object is invalid, returns the @@ -104,6 +116,8 @@ public: * @li If the value in the INI file is 'abc' and the default value an integer value, then validation * fails and the method returns the default value; * @li If the default value is a boolean value, then the method accepts '1', 'true', 'on' and 'yes' as valid values. + * + * @sa eVaf::Common::toVariant() */ QVariant getValue(QString const & paramName, QVariant const & defaultValue = QVariant::Invalid); @@ -114,14 +128,11 @@ public: * @return True if succeeded and false if not * * The setValue() method writes a parameter value to the INI file. Parameters are identified by a section and key name pair - * in the format '<section>/<key>'. For example, if the section is called 'general' and the key is called 'log_level', + * in the format '\/\'. For example, if the section is called 'general' and the key is called 'log_level', * the the name of the parameter should be given as 'general/log_level'. Parameter names are case insensitive. * * The method returns true if the parameter value was written into the INI file and false if not. Use the errorString() method * to get a human-readable error string if writing to the INI file fails. - * - * Writing to an invalid INI file always fails, but the value is still stored into the internal cache. Readin the same parameter - * value returns the new value even if it was actually not stored into the INI file. */ bool setValue(QString const & paramName, QVariant const & value); @@ -136,4 +147,4 @@ private: } // namespace eVaf::Common } // namespace eVaf -#endif // INIFILE_H +#endif // inifile.h