rambrain
regexmatcher.h
Go to the documentation of this file.
1 /* rambrain - a dynamical physical memory extender
2  * Copyright (C) 2015 M. Imgrund, A. Arth
3  * mimgrund (at) mpifr-bonn.mpg.de
4  * arth (at) usm.uni-muenchen.de
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef REGEXMATCHER_H
21 #define REGEXMATCHER_H
22 
23 #include <string>
24 #include <map>
25 #include "common.h"
26 
27 using namespace std;
28 
29 namespace rambrain
30 {
31 
36 {
37 
38 public:
39 
44  enum matchType {
45  integer = 1 << 0,
46  floating = 1 << 1,
47  units = 1 << 2,
48  text = 1 << 3,
49  alphanumtext = 1 << 4,
50  boolean = 1 << 5,
51  swapfilename = 1 << 6
52  };
53 
57  regexMatcher();
58 
65  bool matchConfigBlock ( const string &str, const string &blockname = "default" ) const;
66 
73  pair<string, string> matchKeyEqualsValue ( const string &str, int valueType = alphanumtext ) const;
81  pair<string, string> matchKeyEqualsValue ( const string &str, const string &key, int valueType = alphanumtext ) const;
82 
88  pair<double, string> splitDoubleValueUnit ( const string &str ) const;
94  pair<long long int, string> splitIntegerValueUnit ( const string &str ) const;
95 
102  string substituteHomeDir ( const string &source, const string &homedir ) const;
103 
104 private:
110  string createRegexMatching ( int type ) const;
111 
112 };
113 
114 }
115 
116 #endif // REGEXMATCHER_H
117 
Class to handle regex matching used for parsing configuration files.
Definition: regexmatcher.h:35
STL namespace.
matchType
An enum to caracterise what shall be matched in a specific case; flaggy.
Definition: regexmatcher.h:44