openModeller  Version 1.5.0
my_file_parser.hh
Go to the documentation of this file.
1 
28 #ifndef _FILE_PARSERHH_
29 #define _FILE_PARSERHH_
30 
31 #include <openmodeller/om_defs.hh>
33 
34 #include <vector>
35 #include <string>
36 #include <utility> // for std::pair
37 
42 class FileParser
43 {
44 public:
45 
46  FileParser( std::string const file );
47 
48  ~FileParser();
49 
50  int load( std::string const file );
51 
55  std::string get( std::string const key ) const;
56 
60  std::string get( std::string const section, std::string const key ) const;
61 
65  int count( std::string const key ) const;
66 
70  int count( std::string const section, std::string const key ) const;
71 
75  std::vector<std::string> getAll( std::string const key ) const;
76 
80  std::vector<std::string> getAll( std::string const section, std::string const key ) const;
81 
82 private:
83 
84  typedef std::pair<icstring,std::string> Item;
85  typedef std::vector<Item> ItemList;
86  typedef std::pair<icstring,ItemList> Section;
87  typedef std::vector<Section> SectionList;
88 
91 
95  std::string _get( std::string const key, ItemList lst ) const;
96 
100  int _count( std::string const key, ItemList lst ) const;
101 
105  std::vector<std::string> _getAll( std::string const key, ItemList lst ) const;
106 };
107 
108 #endif
int count(const std::string &key) const
Definition: FileParser.cpp:165
FileParser(const std::string &file)
Definition: FileParser.cpp:47
std::pair< icstring, std::string > Item
int load(const std::string &file)
Definition: FileParser.cpp:68
ItemList f_lst
Definition: FileParser.hh:80
SectionList f_seclst
std::pair< icstring, ItemList > Section
std::vector< Section > SectionList
std::vector< std::string > getAll(const std::string &key) const
Definition: FileParser.cpp:185
int _count(std::string const key, ItemList lst) const
std::string _get(std::string const key, ItemList lst) const
std::vector< std::string > _getAll(std::string const key, ItemList lst) const
std::vector< Item > ItemList