00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef GEDCONF_H
00010 #define GEDCONF_H
00011
00012 #include <map>
00013 #include <vector>
00014 #include <xercesc/dom/DOM.hpp>
00015
00021 typedef std::map<std::string, std::string> PluginDirsList;
00022 typedef PluginDirsList::iterator PluginDirsListIterator;
00023
00029 typedef std::map<std::string, std::string> MacroList;
00030
00034 class GedMacroCommand {
00035 public:
00041 GedMacroCommand (std::string name, std::string param) {
00042 _commandName = name;
00043 _params = param;
00044 };
00045
00050 std::string getName () { return _commandName; }
00051
00056 std::string getParam () { return _params; }
00057
00062 void setName ( std::string name ) { _commandName = name; }
00063
00068 void setParam ( std::string param ) { _params = param; }
00069
00074 void addParam ( std::string param ) { _params += ( " " + param ); }
00075
00076 private:
00077 std::string _commandName;
00078 std::string _params;
00079 };
00080
00084 typedef std::vector<GedMacroCommand> CommandVector;
00085
00091 typedef std::map<std::string, CommandVector> MacroCommands;
00092
00093
00094
00095
00096 class GedConf {
00097 public:
00098 ~GedConf ();
00103 static GedConf *ptr();
00104
00108 static void destroy();
00109
00115 void readConfig ( const char* pathToFile );
00116
00121 void saveConfig ();
00122
00127 PluginDirsList getPluginDirs();
00128
00134 void setPluginDir( const char* pathToDir );
00135
00140 void removePluginDir( const char* pathToDir );
00141
00146 MacroList getMacroList();
00147
00153 CommandVector getCommands( const std::string macroName );
00154
00159 void removeMacro( const std::string macroName );
00160
00167 void addMacro( const char* macroName, const char* commandName, const char* commandParams );
00168
00173 std::string getHelpDir();
00174
00179 std::string getImageDir();
00180
00187 void getFont( std::string &fileName, std::string &dpi, std::string &size);
00188
00189 protected:
00190
00194 GedConf():_change(false){}
00195
00196 private:
00197 static GedConf *_instance;
00198
00199 PluginDirsList _PluginDirs;
00200 MacroList _MacroList;
00201 MacroCommands _MacroCommands;
00202 std::string _helpdir;
00203 std::string _imagesDir;
00204 std::string _fontFile;
00205 std::string _fontDPI;
00206 std::string _fontSize;
00207
00208 std::string _lastCofingFile;
00209
00210 bool _change;
00211 bool _PLFR;
00212 bool _MLFR;
00213 bool _HLFR;
00214 bool _ILFR;
00215 bool _FLFR;
00216
00217 #if XERCES_VERSION_MINOR == 7
00218
00221 void parsePluginDirs( xercesc_2_7::DOMNodeList* listPluginNodes );
00222
00226 void parseMacros( xercesc_2_7::DOMNodeList* listPluginNodes );
00227
00231 void parseNodeWithOneAttribute( xercesc_2_7::DOMNode* Node, const char* nName, std::string &Store, bool* recor);
00232
00236 void parseFont( xercesc_2_7::DOMNode* fontNode );
00237
00241 CommandVector parseMacroCommands( xercesc_2_7::DOMNodeList* listPluginNodes );
00242
00246 void createCommandTree( xercesc_2_7::DOMNode* macroNode, std::string macroName );
00247 #endif
00248 #if XERCES_VERSION_MINOR == 6
00249
00252 void parsePluginDirs( xercesc_2_6::DOMNodeList* listPluginNodes );
00253
00257 void parseMacros( xercesc_2_6::DOMNodeList* listPluginNodes );
00258
00262 void parseNodeWithOneAttribute( xercesc_2_6::DOMNode* Node, const char* nName, std::string &Store, bool* recor);
00263
00267 void parseFont( xercesc_2_6::DOMNode* fontNode );
00268
00272 CommandVector parseMacroCommands( xercesc_2_6::DOMNodeList* listPluginNodes );
00273
00277 void createCommandTree( xercesc_2_6::DOMNode* macroNode, std::string macroName );
00278 #endif
00279
00280 };
00281
00282 #endif