X-Git-Url: https://vaikene.ee/gitweb/gitweb.cgi?a=blobdiff_plain;f=src%2Flibs%2FCommon%2Finifile.h;h=ecf873768a37ff0b51413fcb5596ca347d334217;hb=77854ea7bd165f8d9afd2cba1490335a67001ab7;hp=705bd9bc20795315745fef623bed1fada65005cf;hpb=555fa9e86134fda6e631e9178e50b444b1079e4f;p=evaf diff --git a/src/libs/Common/inifile.h b/src/libs/Common/inifile.h index 705bd9b..ecf8737 100644 --- a/src/libs/Common/inifile.h +++ b/src/libs/Common/inifile.h @@ -43,11 +43,14 @@ namespace Internal { * 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: + * This is a sample INI %file: * @code * [main] * # The full name of this parameter is 'main/name' - * name = MyApplication + * name = "My Application" + * + * # 4-byte binary version number 1.0.7.10 with the name 'main/version' + * version = � * * [extensions/about] * # The full name of this parameter is 'extensions/about/module' @@ -59,14 +62,21 @@ namespace Internal { * of different data types: * * @li Bool - '0', 'false', 'off', 'no' are equal to false and '1', 'true', 'on', 'yes' are equal to true; - * @li Char - a single character or an ASCII code as '\0NNN' or '\0xNN'; + * @li Char - a single character or an UTF-16 code as '\0NNNNNN' (oct) or '\0xNNNN' (hex); * @li Date - date string in the ISO 8601 format YYYY-MM-DD; * @li DateTime - date and time string in the ISO 8601 format YYY-MM-DDTHH:MM:SSTZD; * @li Double - the decimal point is always '.' regardless of the locale; * @li Int - only base 10 (decimal) is allowed; * @li Time - 24h time string in the format HH:MM:SS * @li UInt - base 16 (hex) if the string is prefixed with '0x'; base 8 if the string starts with '0'; otherwise - * the value is expected to be base 10 (decimal). + * the value is expected to be base 10 (decimal); + * @li ByteArray - non-printable bytes and special characters are encoded as numeric character or character entity references; + * @li String - non-printable and special characters are encoded as numeric character or character entity references. + * + * Strings and Byte array values can be enclosed in single or double quotes. The IniFile class does this automatically when + * saving String or Byte array values with leading or trailing spaces. Quotes are removed from the parameter value prior + * returning the value to the application. Use character entity references """ and "'" if quotes should be part of + * the parameter value. */ class COMMON_EXPORT IniFile { @@ -105,7 +115,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 @@ -116,8 +126,10 @@ 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); + QVariant getValue(QByteArray const & paramName, QVariant const & defaultValue = QVariant::Invalid); /** * Writes a value to the INI file. @@ -126,13 +138,13 @@ 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. */ - bool setValue(QString const & paramName, QVariant const & value); + bool setValue(QByteArray const & paramName, QVariant const & value); private: