6 #include "rrExporter.h"
7 #include "rrStringUtils.h"
8 #include "rrIniSection.h"
10 #include "rrFileName.h"
20 const int MAX_LINE_BUFFER_SIZE = 2048;
25 typedef std::vector<IniKey*> KeyList;
26 typedef std::vector<string> NonKeyList;
27 typedef std::vector<IniSection*> SectionList;
28 typedef SectionList::iterator SectionItor;
38 const int mAutoCreateSections;
42 const int mAutoCreateKeys;
44 string mCommentIndicators;
45 const string mEqualIndicator;
46 const string mWhiteSpace;
49 string GetNextWord(
string& CommandLine);
50 string Trim(
string& Str);
51 int WriteLine(fstream& stream,
const char* fmt, ...);
54 SectionList mSections;
63 IniFile(
const string& fName =
"",
bool autoLoad =
false,
bool autoSave =
false);
66 size_t GetNumberOfSections(){
return mSections.size();}
67 IniSection* GetSection(
int i){
return mSections[i];}
68 IniSection* GetSection(
size_t i) {
return mSections[i]; }
71 string GetFilePath(){
return mIniFileName.GetPath();}
72 string GetFileName(){
return mIniFileName;}
73 string GetFullFileName(){
return mIniFileName.GetPathAndFileName();}
74 bool SetFilePath(
const string& path);
75 bool Load(
const string& fName =
"");
76 IniSection* LoadSection(
const string& theSection);
77 bool Save(ios_base::openmode openMode = ios::out|ios::trunc);
78 bool UnLoad(){
return Save();}
79 bool WasItFound(){
return mWasFound;}
84 string ReadValue(
const string& Key,
const string& Section =
"");
85 string ReadString(
const string& Key,
const string& Section =
"",
const string& def_val=
"");
86 double ReadDouble(
const string& Key,
const string& Section =
"",
double def_value = 0);
87 float ReadFloat(
const string& Key,
const string& Section =
"",
double def_value = 0){
return (
float) ReadDouble(Key, Section, def_value);}
88 int ReadInteger(
const string& Key,
const string& Section =
"",
int def_value = 0);
89 bool ReadBool(
const string& Key,
const string& Section =
"",
bool def_value =
false);
92 bool WriteValue(
const string& Key,
const string& Value,
const string& Comment =
"",
const string& Section =
"");
93 bool WriteFloat(
const string& Key,
double value,
const string& Comment =
"",
const string& Section =
"");
94 bool WriteInteger(
const string& Key,
int nValue,
const string& Comment =
"",
const string& Section =
"");
95 bool WriteBool(
const string& Key,
bool bValue,
const string& Comment =
"",
const string& Section =
"");
96 bool WriteString(
const string& Key,
const string& Value,
const string& Comment =
"",
const string& Section =
""){
return WriteValue(Key, Value, Comment, Section);}
97 bool WriteNonKey(
const string& nonKey,
const string& Section =
"");
100 bool SetKeyComment(
const string& Key,
const string& Comment,
const string& Section =
"");
101 bool SetSectionComment(
const string& Section,
const string& Comment);
102 bool DeleteKey(
const string& Key,
const string& FromSection =
"");
103 bool DeleteSection(
const string& Section);
104 bool DeleteSectionsWithKeyValue(
const string& key,
const string& value);
105 bool CreateKey(
const string& Key,
const string& Value,
const string& Comment =
"",
const string& Section =
"");
108 bool CreateSection(
const string& Section,
const string& Comment =
"");
109 bool CreateSection(
const string& Section,
const string& Comment, KeyList Keys);
112 size_t SectionCount();
114 size_t KeyCount(
const string& section);
116 void SetFileName(
const string& fName);
117 string CommentStr(
string& Comment);
118 IniKey* GetKey(
const string& Key,
const string& Section);
119 IniSection* GetSection(
const string& Section,
bool create =
false);
120 IniSection* GetSection(
const unsigned int secNr);
121 bool ClearSection(
const string& section);
122 bool IsModified(){
return mIsDirty;}
Definition: rrFileName.h:17
Definition: rrIniFile.h:34
bool SectionExists(const string §ion)
Boolean indicating if the last key was found in the ini file.
Definition: rrIniSection.h:24