* Author : Boris Mikhailenko <stg34@ua.fm>
*/
- /*
+/*
$Revision: 1.5 $
$Date: 2009/06/22 16:00:38 $
*/
#include <map>
#include <string>
-#include "os_int.h"
+#include "stg/os_int.h"
using namespace std;
//---------------------------------------------------------------------------
class CONFIGFILE
{
-private:
- mutable map<string, string, StringCaseCmp_t> param_val;
- mutable map<string, string>::iterator it;
-
- FILE * f;
- int Flush();
- //int ReadFile();
- string fileName;
- int error;
-
public:
- CONFIGFILE(const string &fn);
+ CONFIGFILE(const string & fn, bool nook = false);
~CONFIGFILE();
const string & GetFileName() const;
- // 5 ÆÕÎËÃÉÉ Read* ×ÏÚ×ÒÁÝÁÀÔ 0 ÐÒÉ ÕÓÐÅÛÎÏÍ ÓÞÉÔÙ×ÁÎÉÉ
+ // æÕÎËÃÉÉ Read* ×ÏÚ×ÒÁÝÁÀÔ 0 ÐÒÉ ÕÓÐÅÛÎÏÍ ÓÞÉÔÙ×ÁÎÉÉ
// É EINVAL ÐÒÉ ÏÔÓÕÔÓ×ÉÉ ÐÁÒÁÍÅÔÒÁ É ×ÙÓÔÁ×ÌÑÀÔ defaulValue
- int ReadString(const string & param, char * val, int * maxLen, const char * defaultVal) const;
+ //int ReadString(const string & param, char * val, int * maxLen, const char * defaultVal) const;
int ReadString(const string & param, string * val, const string & defaultVal) const;
-
- int ReadTime (const string & param, time_t *, time_t) const;
-
- int ReadShortInt (const string & param, short int *, short int) const;
- int ReadInt (const string & param, int *, int) const;
- int ReadLongInt (const string & param, long int *, long int) const;
+ int ReadTime(const string & param, time_t *, time_t) const;
+ int ReadShortInt(const string & param, short int *, short int) const;
+ int ReadInt(const string & param, int *, int) const;
+ int ReadLongInt(const string & param, long int *, long int) const;
int ReadLongLongInt(const string & param, int64_t *, int64_t) const;
-
- int ReadUShortInt (const string & param, unsigned short int *, unsigned short int) const;
- int ReadUInt (const string & param, unsigned int *, unsigned int) const;
- int ReadULongInt (const string & param, unsigned long int *, unsigned long int) const;
+ int ReadUShortInt(const string & param, unsigned short int *, unsigned short int) const;
+ int ReadUInt(const string & param, unsigned int *, unsigned int) const;
+ int ReadULongInt(const string & param, unsigned long int *, unsigned long int) const;
int ReadULongLongInt(const string & param, uint64_t *, uint64_t) const;
+ int ReadDouble(const string & param, double * val, double defaultVal) const;
+
+ void WriteString(const string & param, const char * val) { return WriteString(param, std::string(val)); }
+ void WriteString(const string & param, const string & val);
+ void WriteInt(const string & param, int64_t val);
+ void WriteDouble(const string & param, double val);
- int ReadDouble (const string & param, double * val, double defaultVal) const;
+ int Error() const;
+ int Flush() const;
- int WriteString(const string & param, const char * val);
- int WriteString(const string & param, const string & val);
- int WriteInt (const string & param, int64_t val);
- int WriteDouble(const string & param, double val);
+private:
+ map<string, string, StringCaseCmp_t> param_val;
+ string fileName;
+ mutable int error;
+ mutable bool changed;
- int Error();
+ int Flush(const std::string & path) const;
};
//---------------------------------------------------------------------------
#endif