openModeller
Version 1.4.0
|
00001 00028 #ifndef _FILE_PARSERHH_ 00029 #define _FILE_PARSERHH_ 00030 00031 #include <openmodeller/om_defs.hh> 00032 #include <openmodeller/ignorecase_traits.hh> 00033 00034 #include <vector> 00035 #include <string> 00036 #include <utility> // for std::pair 00037 00042 class FileParser 00043 { 00044 public: 00045 00046 FileParser( std::string const file ); 00047 00048 ~FileParser(); 00049 00050 int load( std::string const file ); 00051 00055 std::string get( std::string const key ) const; 00056 00060 std::string get( std::string const section, std::string const key ) const; 00061 00065 int count( std::string const key ) const; 00066 00070 int count( std::string const section, std::string const key ) const; 00071 00075 std::vector<std::string> getAll( std::string const key ) const; 00076 00080 std::vector<std::string> getAll( std::string const section, std::string const key ) const; 00081 00082 private: 00083 00084 typedef std::pair<icstring,std::string> Item; 00085 typedef std::vector<Item> ItemList; 00086 typedef std::pair<icstring,ItemList> Section; 00087 typedef std::vector<Section> SectionList; 00088 00089 ItemList f_lst; 00090 SectionList f_seclst; 00091 00095 std::string _get( std::string const key, ItemList lst ) const; 00096 00100 int _count( std::string const key, ItemList lst ) const; 00101 00105 std::vector<std::string> _getAll( std::string const key, ItemList lst ) const; 00106 }; 00107 00108 #endif