00001 /*!\file configreader.h 00002 \brief Declerations for ConfigPair and ConfigReader. 00003 Should be included to use the ConfigReader*/ 00004 00005 #ifndef __CONFIGREADER_H__ 00006 #define __CONFIGREADER_H__ 00007 00008 #include "pmstring.h" 00009 #include <vector> 00010 00011 //!Used to store the variable/value pairs. 00012 /*!A small struct that is used to store the variable/value pairs for the 00013 ConfigReader class. This should only be needed by the ConfigReader class 00014 itself.*/ 00015 struct ConfigPair 00016 { 00017 PMString variable; //!<The variable name. 00018 PMString value; //!<The value of the variable. 00019 }; 00020 00021 //!The class used to read config files in easily. 00022 /*!The main config reader class. Used to read config files of the form 00023 VARIABLE HERE = VALUE HERE. Spaces can be used to format however the 00024 config designer wishes. Comments can be written using '#' as a delimeter. 00025 The class also ignores lines without an '=', but using this as comments 00026 is bad practice.*/ 00027 class ConfigReader 00028 { 00029 public: 00030 ConfigReader(bool buffer = false); //!<Constructor. 00031 ConfigReader(PMString fileName, bool buffer = false); //!<Constructor. 00032 ~ConfigReader(); //!<Destructor. 00033 00034 void SetBuffered(bool buffer); //!<Sets the buffer bool and buffers accordingly. 00035 void SetFileName(PMString fileName); //!<Set the filename. 00036 void BufferReader(); //!<Buffer the reader. 00037 PMString GetFileName(); //!<Return the filename. 00038 PMString GetConfigValue(PMString variable); //!<Return a config variable. 00039 std::vector<PMString> ListVariables(); //!<List all the variables in the reader. 00040 00041 protected: 00042 bool _buffered; //!<Is the reader buffered? 00043 PMString _fileName; //!<The filename. 00044 std::vector<ConfigPair> _configPairs; //!<The ConfigPairs in the reader. 00045 }; 00046 00047 #endif