diff options
author | Chris Wilson <chris+github@qwirx.com> | 2007-07-26 22:08:21 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2007-07-26 22:08:21 +0000 |
commit | 88edb51fc08aa8dfe1fed4c614343d1f2405dac9 (patch) | |
tree | 782403d864d9b68e50de9bf17aac821d6609b844 | |
parent | 273e5baec103e402d81004190413b3efd131716b (diff) |
Make Configuration take a std::string filename instead of a char array,
in C++ style. (refs #3, merges [1684])
-rw-r--r-- | lib/common/Configuration.cpp | 13 | ||||
-rw-r--r-- | lib/common/Configuration.h | 11 |
2 files changed, 14 insertions, 10 deletions
diff --git a/lib/common/Configuration.cpp b/lib/common/Configuration.cpp index def93571..5f9376c5 100644 --- a/lib/common/Configuration.cpp +++ b/lib/common/Configuration.cpp @@ -83,19 +83,16 @@ Configuration::~Configuration() // Created: 2003/07/23 // // -------------------------------------------------------------------------- -std::auto_ptr<Configuration> Configuration::LoadAndVerify(const char *Filename, const ConfigurationVerify *pVerify, std::string &rErrorMsg) +std::auto_ptr<Configuration> Configuration::LoadAndVerify( + const std::string& rFilename, + const ConfigurationVerify *pVerify, + std::string &rErrorMsg) { - // Check arguments - if(Filename == 0) - { - THROW_EXCEPTION(CommonException, BadArguments) - } - // Just to make sure rErrorMsg.erase(); // Open the file - FileHandleGuard<O_RDONLY> file(Filename); + FileHandleGuard<O_RDONLY> file(rFilename); // GetLine object FdGetLine getline(file); diff --git a/lib/common/Configuration.h b/lib/common/Configuration.h index 4c455b0f..64e7568e 100644 --- a/lib/common/Configuration.h +++ b/lib/common/Configuration.h @@ -69,8 +69,15 @@ public: MultiValueSeparator = '\x01' }; - static std::auto_ptr<Configuration> LoadAndVerify(const char *Filename, const ConfigurationVerify *pVerify, std::string &rErrorMsg); - static std::auto_ptr<Configuration> Load(const char *Filename, std::string &rErrorMsg) { return LoadAndVerify(Filename, 0, rErrorMsg); } + static std::auto_ptr<Configuration> LoadAndVerify( + const std::string& rFilename, + const ConfigurationVerify *pVerify, + std::string &rErrorMsg); + + static std::auto_ptr<Configuration> Load( + const std::string& rFilename, + std::string &rErrorMsg) + { return LoadAndVerify(rFilename, 0, rErrorMsg); } bool KeyExists(const char *pKeyName) const; const std::string &GetKeyValue(const char *pKeyName) const; |