Guest
Public paste!

Untitled

By: a guest | Sep 9th, 2010 | Syntax: C++ | Size: 0.85 KB | Hits: 67 | Expires: Never
Copy text to clipboard
  1. #ifndef CONFIG_H
  2. #define CONFIG_H
  3.  
  4. #include "Common.h"
  5. #include <fstream>
  6. #include <boost/regex.hpp>
  7.  
  8. class Config {
  9. public:
  10.         Config(std::string ConfigFileName);
  11.         void ReloadConfig();
  12.         std::string GetStringDefault(std::string Name, std::string DefaultValue = "");
  13.         bool GetBoolDefault(std::string Name, bool DefaultValue = false);
  14.         int GetIntDefault(std::string Name, int DefaultValue = 0);
  15.         float GetFloatDefault(std::string Name, float DefaultValue = 0);
  16.  
  17.         std::string GetFileName()
  18.         {
  19.                 return this->configFileName;
  20.         }
  21.         ~Config();
  22. private:
  23.         std::string configFileName;
  24.         std::ifstream fileStream;
  25.         boost::regex searchPattern;
  26.         stringMapType configMap;
  27.  
  28.         //--used for threading
  29.         boost::mutex lineBufferMutex;
  30.         boost::mutex configMapMutex;
  31.         std::list<std::string> lineBuffer;
  32.         bool isFileFinish;
  33.         void lineParser();
  34.         //--
  35. };
  36. #endif