merged tag ooo/DEV300_m102
[LibreOffice.git] / l10ntools / inc / inireader.hxx
blob0861290adf9f2dfd275dc872d9ead9cbf90095e4
1 #include <string>
2 #include <hash_map>
3 #include <unicode/regex.h>
5 using namespace std;
7 namespace transex3
10 struct eqstr
12 bool operator()( const string s1 , const string s2) const
14 return s1.compare( s2 ) == 0;
18 typedef std::hash_map< string , string > stringmap;
19 typedef std::hash_map< string, stringmap* > INImap;
21 class INIreader
23 private:
24 UErrorCode section_status;
25 UErrorCode parameter_status;
26 RegexMatcher* section_match;
27 RegexMatcher* parameter_match;
29 public:
30 INIreader(): section_status ( U_ZERO_ERROR ) ,
31 parameter_status ( U_ZERO_ERROR )
33 section_match = new RegexMatcher ( "^\\s*\\[([a-zA-Z0-9]*)\\].*" , 0 , section_status );
34 parameter_match = new RegexMatcher ( "^\\s*([a-zA-Z0-9]*)\\s*=\\s*([a-zA-Z0-9 ]*).*" , 0 , parameter_status ) ;
36 ~INIreader()
38 delete section_match;
39 delete parameter_match;
41 // open "filename", fill hash_map with sections / paramaters
42 bool read( INImap& myMap , string& filename );
44 private:
45 bool is_section( string& line , string& section_str );
46 bool is_parameter( string& line , string& parameter_key , string& parameter_value );
47 inline void check_status( UErrorCode status );
48 inline void toStlString ( const UnicodeString& str, string& stl_str );
49 inline void trim( string& str );