From 5d95d24dd21dd49fdfb468a47ce87bb9ab8104b5 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 19 Jul 2002 22:22:19 +0000 Subject: [PATCH] use the _variable member naming convention --- src/Configuration.cc | 126 ++++++++++++++++++++++--------------------- src/Configuration.hh | 16 +++--- 2 files changed, 73 insertions(+), 69 deletions(-) diff --git a/src/Configuration.cc b/src/Configuration.cc index 237b4a63..52e1b272 100644 --- a/src/Configuration.cc +++ b/src/Configuration.cc @@ -20,151 +20,155 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#ifdef HAVE_CONFIG_H #include "../config.h" +#endif // HAVE_CONFIG_H + +extern "C" { +#ifdef HAVE_STDLIB_H +# include +#endif // HAVE_STDLIB_H +} #include "Configuration.hh" #include "Util.hh" #include -#ifdef HAVE_STDLIB_H -# include -#endif // HAVE_STDLIB_H - using std::string; -bool Configuration::m_initialized = False; +bool Configuration::_initialized = False; Configuration::Configuration(const string &file, bool autosave) { setFile(file); - m_modified = False; - m_database = NULL; - m_autosave = autosave; - if (! m_initialized) { + _modified = False; + _database = NULL; + _autosave = autosave; + if (! _initialized) { XrmInitialize(); - m_initialized = True; + _initialized = True; } } Configuration::Configuration(bool autosave) { - m_modified = False; - m_database = NULL; - m_autosave = autosave; - if (! m_initialized) { + _modified = False; + _database = NULL; + _autosave = autosave; + if (! _initialized) { XrmInitialize(); - m_initialized = True; + _initialized = True; } } Configuration::~Configuration() { - if (m_database != NULL) - XrmDestroyDatabase(m_database); + if (_database != NULL) + XrmDestroyDatabase(_database); } void Configuration::setFile(const string &file) { - m_file = file; + _file = file; } void Configuration::setAutoSave(bool autosave) { - m_autosave = autosave; + _autosave = autosave; } void Configuration::save() { - assert(m_database != NULL); - XrmPutFileDatabase(m_database, m_file.c_str()); - m_modified = False; + assert(_database != NULL); + XrmPutFileDatabase(_database, _file.c_str()); + _modified = False; } bool Configuration::load() { - if (m_database != NULL) - XrmDestroyDatabase(m_database); - m_modified = False; - if (NULL == (m_database = XrmGetFileDatabase(m_file.c_str()))) + if (_database != NULL) + XrmDestroyDatabase(_database); + _modified = False; + if (NULL == (_database = XrmGetFileDatabase(_file.c_str()))) return False; return True; } bool Configuration::merge(const string &file, bool overwrite) { - if (XrmCombineFileDatabase(file.c_str(), &m_database, overwrite) == 0) + if (XrmCombineFileDatabase(file.c_str(), &_database, overwrite) == 0) return False; - m_modified = True; - if (m_autosave) + _modified = True; + if (_autosave) save(); return True; } void Configuration::create() { - if (m_database != NULL) - XrmDestroyDatabase(m_database); - m_modified = False; - assert(NULL != (m_database = XrmGetStringDatabase(""))); + if (_database != NULL) + XrmDestroyDatabase(_database); + _modified = False; + assert(NULL != (_database = XrmGetStringDatabase(""))); } void Configuration::setValue(const string &rname, bool value) { - assert(m_database != NULL); + assert(_database != NULL); const char *val = (value ? "True" : "False"); string rc_string = rname + ": " + val; - XrmPutLineResource(&m_database, rc_string.c_str()); + XrmPutLineResource(&_database, rc_string.c_str()); - m_modified = True; - if (m_autosave) + _modified = True; + if (_autosave) save(); } void Configuration::setValue(const string &rname, unsigned long value) { - assert(m_database != NULL); + assert(_database != NULL); string rc_string = rname + ": " + itostring(value); - XrmPutLineResource(&m_database, rc_string.c_str()); + XrmPutLineResource(&_database, rc_string.c_str()); - m_modified = True; - if (m_autosave) + _modified = True; + if (_autosave) save(); } void Configuration::setValue(const string &rname, long value) { - assert(m_database != NULL); + assert(_database != NULL); string rc_string = rname + ": " + itostring(value); - XrmPutLineResource(&m_database, rc_string.c_str()); + XrmPutLineResource(&_database, rc_string.c_str()); - m_modified = True; - if (m_autosave) + _modified = True; + if (_autosave) save(); } void Configuration::setValue(const string &rname, const char *value) { - assert(m_database != NULL); + assert(_database != NULL); assert(value != NULL); string rc_string = rname + ": " + value; - XrmPutLineResource(&m_database, rc_string.c_str()); + XrmPutLineResource(&_database, rc_string.c_str()); - m_modified = True; - if (m_autosave) + _modified = True; + if (_autosave) save(); } void Configuration::setValue(const string &rname, const string &value) { - assert(m_database != NULL); + assert(_database != NULL); string rc_string = rname + ": " + value; - XrmPutLineResource(&m_database, rc_string.c_str()); + XrmPutLineResource(&_database, rc_string.c_str()); - m_modified = True; - if (m_autosave) + _modified = True; + if (_autosave) save(); } bool Configuration::getValue(const string &rname, bool &value) const { - assert(m_database != NULL); + assert(_database != NULL); string rclass = createClassName(rname); char *rettype; XrmValue retvalue; - if (0 == XrmGetResource(m_database, rname.c_str(), rclass.c_str(), + if (0 == XrmGetResource(_database, rname.c_str(), rclass.c_str(), &rettype, &retvalue) || retvalue.addr == NULL) return False; string val = retvalue.addr; @@ -176,13 +180,13 @@ bool Configuration::getValue(const string &rname, bool &value) const { } bool Configuration::getValue(const string &rname, long &value) const { - assert(m_database != NULL); + assert(_database != NULL); string rclass = createClassName(rname); char *rettype; XrmValue retvalue; - if (0 == XrmGetResource(m_database, rname.c_str(), rclass.c_str(), + if (0 == XrmGetResource(_database, rname.c_str(), rclass.c_str(), &rettype, &retvalue) || retvalue.addr == NULL) return False; char *end; @@ -193,13 +197,13 @@ bool Configuration::getValue(const string &rname, long &value) const { } bool Configuration::getValue(const string &rname, unsigned long &value) const { - assert(m_database != NULL); + assert(_database != NULL); string rclass = createClassName(rname); char *rettype; XrmValue retvalue; - if (0 == XrmGetResource(m_database, rname.c_str(), rclass.c_str(), + if (0 == XrmGetResource(_database, rname.c_str(), rclass.c_str(), &rettype, &retvalue) || retvalue.addr == NULL) return False; char *end; @@ -211,13 +215,13 @@ bool Configuration::getValue(const string &rname, unsigned long &value) const { bool Configuration::getValue(const string &rname, string &value) const { - assert(m_database != NULL); + assert(_database != NULL); string rclass = createClassName(rname); char *rettype; XrmValue retvalue; - if (0 == XrmGetResource(m_database, rname.c_str(), rclass.c_str(), + if (0 == XrmGetResource(_database, rname.c_str(), rclass.c_str(), &rettype, &retvalue) || retvalue.addr == NULL) return False; value = retvalue.addr; diff --git a/src/Configuration.hh b/src/Configuration.hh index b26541fd..8f4a3157 100644 --- a/src/Configuration.hh +++ b/src/Configuration.hh @@ -42,18 +42,18 @@ public: virtual ~Configuration(); inline const std::string &file() const { - return static_cast(m_file); + return static_cast(_file); } void setFile(const std::string &file); // defaults to true! inline bool autoSave() const { - return m_autosave; + return _autosave; } void setAutoSave(bool); inline bool isModified() const { - return m_modified; + return _modified; } void save(); @@ -88,11 +88,11 @@ private: std::string createClassName(const std::string &rname) const; char toUpper(char) const; - static bool m_initialized; - std::string m_file; - bool m_modified; - bool m_autosave; - XrmDatabase m_database; + static bool _initialized; + std::string _file; + bool _modified; + bool _autosave; + XrmDatabase _database; }; #endif // __Configuration_hh -- 2.45.2