Debian Codegraph @

HercConfiguration/ConfigLine.h

raw symbols SCIP
1 /*
2 * File: ConfigLine.h
3 *
4 * Author: Jacob Dekel
5 * Created on: Aug 7, 2009
6 *
7 * Copyright (c) 2009-2013 Jacob Dekel
8 * $Id$
9 *
10 * This object manages one line of the configuration file
11 *
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 *
25 */
26
27 #ifndef CONFIGLINE_H
28 #define CONFIGLINE_H
29
30 #include <string>
31 #include <utility>
32 #include <vector>
33
34 typedef std::pair<int,int> TokenPair;
35
36 class ConfigLine
37 {
38 public:
39 ConfigLine(const char *line);
40 virtual ~ConfigLine();
41
42 void replaceLine(const std::string& newLine);
43 void replaceParameters(const std::string& newParm);
44 void setDeleted(bool parm);
45 const std::string& getLine() const;
46 inline bool isRemark() const { return mRemark; }
47 inline bool isDeleted() const { return mDeleted; }
48 inline bool isNew() const { return mNew; }
49 inline bool isUpdated() const { return mUpdated; }
50 inline bool inError() const { return mInError; }
51 inline int errorColumn() const { return mErrorColumn; }
52
53 inline void setNew(bool newVal) { mNew=newVal; } ;
54 inline void setUpdated(bool updated) { mUpdated=updated; } ;
55 inline void setInError(int column) const { mInError=true; mErrorColumn=column; }
56 inline void setNoError() const { mInError=false; mErrorColumn=-1; }
57
58 std::string getToken(int i) const;
59 std::string getLowercaseToken(int i) const;
60 std::string getUppercaseToken(int i) const;
61 int getAbsoluteTokenColumn(int i) const;
62 int getAbsoluteTokenEnd(int i) const;
63 std::string getMultiToken(int from, int to) const;
64 inline int size() const {return mSize;}
65 void parseLine();
66
67 protected:
68 std::string mLine;
69
70 private:
71 bool mRemark;
72 bool mDeleted;
73 bool mUpdated;
74 bool mNew;
75 int mSize;
76 mutable bool mInError;
77 mutable int mErrorColumn;
78 std::string::size_type mKeyStart;
79 std::string mKeyword;
80 std::vector<TokenPair> mTokens;
81
82 void tokenize(const std::string& delimiters = " ");
83 };
84
85 #endif // #ifdef CONFIGLINE_H