00001 00039 #ifndef ASYNC_CONFIG_INCLUDED 00040 #define ASYNC_CONFIG_INCLUDED 00041 00042 00043 /**************************************************************************** 00044 * 00045 * System Includes 00046 * 00047 ****************************************************************************/ 00048 00049 #include <stdio.h> 00050 00051 #include <string> 00052 #include <map> 00053 #include <list> 00054 00055 00056 /**************************************************************************** 00057 * 00058 * Project Includes 00059 * 00060 ****************************************************************************/ 00061 00062 00063 00064 /**************************************************************************** 00065 * 00066 * Local Includes 00067 * 00068 ****************************************************************************/ 00069 00070 00071 00072 /**************************************************************************** 00073 * 00074 * Forward declarations 00075 * 00076 ****************************************************************************/ 00077 00078 00079 00080 /**************************************************************************** 00081 * 00082 * Namespace 00083 * 00084 ****************************************************************************/ 00085 00086 namespace Async 00087 { 00088 00089 00090 /**************************************************************************** 00091 * 00092 * Forward declarations of classes inside of the declared namespace 00093 * 00094 ****************************************************************************/ 00095 00096 00097 00098 /**************************************************************************** 00099 * 00100 * Defines & typedefs 00101 * 00102 ****************************************************************************/ 00103 00104 00105 00106 /**************************************************************************** 00107 * 00108 * Exported Global Variables 00109 * 00110 ****************************************************************************/ 00111 00112 00113 00114 /**************************************************************************** 00115 * 00116 * Class definitions 00117 * 00118 ****************************************************************************/ 00119 00134 class Config 00135 { 00136 public: 00140 Config(void); 00141 00145 ~Config(void); 00146 00152 bool open(const std::string& name); 00153 00163 bool getValue(const std::string& section, const std::string& tag, 00164 std::string& value); 00165 00172 std::list<std::string> listSection(const std::string& section); 00173 00174 //bool setValue(const std::string& section, const std::string& tag, 00175 // const std::string& value); 00176 00177 protected: 00178 00179 private: 00180 typedef std::map<std::string, std::string> Values; 00181 typedef std::map<std::string, Values> Sections; 00182 00183 FILE *file; 00184 Sections sections; 00185 00186 bool parseCfgFile(void); 00187 char *trimSpaces(char *line); 00188 char *parseSection(char *line); 00189 char *parseDelimitedString(char *str, char begin_tok, char end_tok); 00190 bool parseValueLine(char *line, std::string& tag, std::string& value); 00191 char *parseValue(char *value); 00192 char *translateEscapedChars(char *val); 00193 00194 }; /* class Config */ 00195 00196 00197 } /* namespace */ 00198 00199 #endif /* ASYNC_CONFIG_INCLUDED */ 00200 00201 00202 00203 /* 00204 * This file has not been truncated 00205 */ 00206