1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "nel/misc/config_file.h"
22 using namespace NLMISC
;
25 // ---------------------------------------------------------------------------
32 // ---------------------------------------------------------------------------
43 // ---------------------------------------------------------------------------
44 bool IEasyCFG::openRead (const std::string
&filename
)
48 FILE *fTemp
= fopen (filename
.c_str(), "rt");
65 // ---------------------------------------------------------------------------
66 bool IEasyCFG::openWrite (const std::string
&filename
)
68 f
= fopen (filename
.c_str(), "wt");
74 // ---------------------------------------------------------------------------
75 void IEasyCFG::close ()
85 // ---------------------------------------------------------------------------
86 sint32
IEasyCFG::getInt (const string
&sVarName
)
92 CConfigFile::CVar
&cv
= cf
->getVar(sVarName
);
101 // ---------------------------------------------------------------------------
102 void IEasyCFG::putInt (const string
&sVarName
, sint32 sVarValue
)
106 fprintf (f
, "%s = %d;\n", sVarName
.c_str(), sVarValue
);
109 // ---------------------------------------------------------------------------
110 string
IEasyCFG::getStr (const string
&sVarName
)
116 CConfigFile::CVar
&cv
= cf
->getVar(sVarName
);
117 return cv
.asString();
125 // ---------------------------------------------------------------------------
126 void IEasyCFG::putStr (const string
&sVarName
, const string
&sVarValue
)
130 fprintf (f
, "%s = \"%s\";\n", sVarName
.c_str(), sVarValue
.c_str());
133 // ---------------------------------------------------------------------------
134 bool IEasyCFG::getBool (const string
&sVarName
)
138 return (getStr (sVarName
) == "true" ? true : false);
141 // ---------------------------------------------------------------------------
142 void IEasyCFG::putBool (const string
&sVarName
, bool sVarValue
)
147 fprintf (f
, "%s = \"true\";\n", sVarName
.c_str());
149 fprintf (f
, "%s = \"false\";\n", sVarName
.c_str());
152 // ---------------------------------------------------------------------------
153 void IEasyCFG::putCommentLine (const std::string
&sComments
)
157 fprintf (f
, "// %s\n", sComments
.c_str());