00001 /****************************************************************************\ 00002 * VRVis * 00003 * http://vrvis.sourceforge.net * 00004 * (C) 2004 by Alex Loeffler * 00005 * mailto:aloeffler@users.sourceforge.net * 00006 **************************************************************************** 00007 * License * 00008 * * 00009 * This library is free software; you can redistribute it and/or modify it * 00010 * under the terms of the GNU Library General Public License as published * 00011 * by the Free Software Foundation, version 2. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, but * 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * Library General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Library General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00021 \****************************************************************************/ 00022 00023 #ifndef CFGREADER_HPP 00024 #define CFGREADER_HPP 00025 00026 #include <map> 00027 #include <string> 00028 #include "Common.hpp" 00029 00030 namespace vrvis 00031 { 00032 00034 class ConfigReader 00035 { 00036 // ================================================================== PUBLIC 00037 00038 public: 00039 00040 // ----------------------------------------------- Constructor & Destructor. 00042 00044 ConfigReader(const std::string& crFilename); 00045 00047 ~ConfigReader(void); 00048 00050 // -------------------------------------------------------------- Accessors. 00052 00054 const std::string& getFilename(void); 00055 00057 std::map<std::string, std::string>& getKeyValueMap(void); 00058 00060 // ================================================================= PRIVATE 00061 00062 private: 00063 00064 // --------------------------------------------------------------- Typedefs. 00065 00067 typedef std::map<std::string, std::string> StringMap; 00068 00069 // ------------------------------------------------------------- File Input. 00070 00072 void readKeyValuePairs(std::ifstream& rStream, 00073 StringMap& rKeyValueSet); 00074 00075 // ---------------------------------------------------------------- Members. 00076 00077 const std::string mcFilename; 00078 StringMap mKeyValueMap; 00079 00080 // --------------------------------------------------------- Static Members. 00081 00083 static const int scLineLength; 00084 }; 00085 00086 } // End namespace. 00087 00088 #endif // CFGREADER_HPP