Debian Codegraph @

Kernel/configure.h

raw symbols SCIP
1 /* This file is part of the FaCT++ DL reasoner
2 Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester
3 Copyright (C) 2015-2017 Dmitry Tsarkov
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #ifndef CONFIGURE_H
21 #define CONFIGURE_Hcxx . . $ `Kernel/configure.h:21:9`!
22
23 const unsigned MaxConfLineLencxx . . $ MaxConfLineLen. = 1024;
24
25 #include <cstring>
26 #include <cstdlib>
27 #include <iosfwd>
28
29 #include <string>
30 #include <vector>
31
32 /// configure element in the form Name = Value
33 class ConfElemcxx . . $ ConfElem#
34 {
35 public: // members
36 /// name of the field
37 const stdcxx . . $ std/::stringcxx . . $ std/string# Namecxx . . $ ConfElem#Name.;
38 /// value of the field
39 stdcxx . . $ std/::stringcxx . . $ std/string# Valuecxx . . $ ConfElem#Value.;
40
41 public: // interface
42 /// empty c'tor
43 ConfElemcxx . . $ ConfElem#ConfElem(49f6e7a06ebc5aa8).() = default;
44 /// init c'tor
45 ConfElemcxx . . $ ConfElem#ConfElem(c3ca1c130ce09c52). ( const stdcxx . . $ std/::stringcxx . . $ std/string#& n, const stdcxx . . $ std/::stringcxx . . $ std/string#& v ) : Namecxx . . $ ConfElem#Name. (n), Valuecxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5). (v) {}
46
47 /// save element to target stream
48 void Savecxx . . $ ConfElem#Save(490063bd7e6d8d5d). ( stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& o ) const;
49
50 // interface
51 long GetLongcxx . . $ ConfElem#GetLong(57a65ae535d7db84). ( void ) const { return stdcxx . . $ std/::stolcxx . . $ std/__cxx11/stol(85082be2742e71bc).(Valuecxx . . $ ConfElem#Value.); }
52 double GetDoublecxx . . $ ConfElem#GetDouble(21b6c25e127938e2). ( void ) const { return atof ( Valuecxx . . $ ConfElem#Value..c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).() ); }
53 const char* GetStringcxx . . $ ConfElem#GetString(a9f41ea0e82d88cf). ( void ) const { return Valuecxx . . $ ConfElem#Value..c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).(); }
54 }; // ConfElem
55
56 /// class for storing configure section with all the keys
57 class ConfSectioncxx . . $ ConfSection#
58 {
59 protected:
60 const stdcxx . . $ std/::stringcxx . . $ std/string# Namecxx . . $ ConfSection#Name.;
61
62 typedef stdcxx . . $ std/::vectorcxx . . $ std/vector# <ConfElemcxx . . $ ConfElem#*> ConfBasecxx . . $ ConfSection#ConfBase#;
63 ConfBasecxx . . $ ConfSection#ConfBase# Basecxx . . $ ConfSection#Base.;
64
65 public:
66 explicit ConfSectioncxx . . $ ConfSection#ConfSection(9c546c94e5fcce4e). ( const stdcxx . . $ std/::stringcxx . . $ std/string#& pc ) : Namecxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5). ( pc ) {}
67 ~cxx . . $ ConfSection#`~ConfSection`(49f6e7a06ebc5aa8).ConfSectioncxx . . $ ConfSection#();
68
69 bool operatorcxx . . $ ConfSection#`operator==`(13a55b95a0133754). == ( const stdcxx . . $ std/::stringcxx . . $ std/string#& pc ) const { return ( Namecxx . . $ ConfSection#Name. ==cxx . . $ std/`operator==`(2965e344aacb545b). pc ); }
70 bool operatorcxx . . $ ConfSection#`operator!=`(13a55b95a0133754). != ( const stdcxx . . $ std/::stringcxx . . $ std/string#& pc ) const { return ( Namecxx . . $ ConfSection#Name. !=cxx . . $ std/`operator!=`(2965e344aacb545b). pc ); }
71
72 void addEntrycxx . . $ ConfSection#addEntry(c3ca1c130ce09c52). ( const stdcxx . . $ std/::stringcxx . . $ std/string#& Name, const stdcxx . . $ std/::stringcxx . . $ std/string#& Value );
73
74 // find element; return NULL if not found
75 ConfElemcxx . . $ ConfElem#* FindByNamecxx . . $ ConfSection#FindByName(b61d646b7f8a015a). ( const stdcxx . . $ std/::stringcxx . . $ std/string#& name ) const;
76
77 void Savecxx . . $ ConfSection#Save(490063bd7e6d8d5d). ( stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& o ) const;
78 }; // ConfSection
79
80 /// class for reading general configuration file
81 class Configurationcxx . . $ Configuration#
82 {
83 protected: // parsing part
84 stdcxx . . $ std/::stringcxx . . $ std/string# fileNamecxx . . $ Configuration#fileName.; // fileName
85 char Linecxx . . $ Configuration#Line. [MaxConfLineLencxx . . $ MaxConfLineLen.+1]; // \0
86 bool isLoadedcxx . . $ Configuration#isLoaded. = false; // flags
87 bool isSavedcxx . . $ Configuration#isSaved. = false;
88
89 // parser methods
90 void loadStringcxx . . $ Configuration#loadString(21eaf1e8e1bd68f5). ( stdcxx . . $ std/::istreamcxx . . $ std/istream#& );
91 bool isCommentcxx . . $ Configuration#isComment(50ce9a9e25b4a850). ( void ) const;
92 bool isSectioncxx . . $ Configuration#isSection(50ce9a9e25b4a850). ( void ) const
93 { return ( Linecxx . . $ Configuration#Line. [0] == '[' && Linecxx . . $ Configuration#Line. [strlen(Linecxx . . $ Configuration#Line.)-1] == ']' ); }
94 void loadSectioncxx . . $ Configuration#loadSection(49f6e7a06ebc5aa8). ( void );
95 // splits line 'name=value' on 2 ASCIIZ parts
96 int SplitLinecxx . . $ Configuration#SplitLine(c31b88f480a969c1). ( char*& pName, char*& pValue );
97
98 protected: // logic part
99 typedef stdcxx . . $ std/::vectorcxx . . $ std/vector# <ConfSectioncxx . . $ ConfSection#*> ConfSectBasecxx . . $ Configuration#ConfSectBase#;
100 ConfSectBasecxx . . $ Configuration#ConfSectBase# Basecxx . . $ Configuration#Base.;
101 ConfSectioncxx . . $ ConfSection#* Sectioncxx . . $ Configuration#Section. = nullptr;
102 ConfElemcxx . . $ ConfElem#* Elementcxx . . $ Configuration#Element. = nullptr;
103
104 // navigation methods
105 ConfSectioncxx . . $ ConfSection#* FindSectioncxx . . $ Configuration#FindSection(3eefb06bfae2ad5f). ( const stdcxx . . $ std/::stringcxx . . $ std/string#& pc ) const;
106
107 public: // interface
108 /// init c'tor
109 Configurationcxx . . $ Configuration#Configuration(49f6e7a06ebc5aa8).() = default;
110 /// no copy c'tor
111 Configurationcxx . . $ Configuration#Configuration(659ed2fe9c88d9c8). ( const Configurationcxx . . $ Configuration#& ) = delete;
112 /// no assignment
113 Configurationcxx . . $ Configuration#& operatorcxx . . $ Configuration#`operator=`(bee1767fa3b670ce). = ( const Configurationcxx . . $ Configuration#& ) = delete;
114 /// d'tor
115 ~cxx . . $ Configuration#`~Configuration`(49f6e7a06ebc5aa8).Configurationcxx . . $ Configuration#();
116
117 // load config from file; @return true if cannot
118 bool Loadcxx . . $ Configuration#Load(c5f7da30cbc0f4e9). ( const char* Filename );
119 // save config to file; @return true if cannot
120 bool Savecxx . . $ Configuration#Save(c5f7da30cbc0f4e9). ( const char* Filename );
121 // save config to the loaded file; @return true if cannot
122 bool Savecxx . . $ Configuration#Save(c9857a73d68e59ba). ( void ) { return isLoadedcxx . . $ Configuration#isLoaded. ? Savecxx . . $ Configuration#Save(c5f7da30cbc0f4e9).(fileNamecxx . . $ Configuration#fileName..c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).()) : true; }
123
124 // status methods
125 bool Loadedcxx . . $ Configuration#Loaded(50ce9a9e25b4a850). ( void ) const { return isLoadedcxx . . $ Configuration#isLoaded.; }
126 bool Savedcxx . . $ Configuration#Saved(50ce9a9e25b4a850). ( void ) const { return isSavedcxx . . $ Configuration#isSaved.; }
127 /// add section if necessary; set Current to new pointer
128 void createSectioncxx . . $ Configuration#createSection(9c546c94e5fcce4e). ( const stdcxx . . $ std/::stringcxx . . $ std/string#& name );
129 /// check if Sect.Field exists;
130 bool checkValuecxx . . $ Configuration#checkValue(1667653f663d0d88). ( const stdcxx . . $ std/::stringcxx . . $ std/string#& Section, const stdcxx . . $ std/::stringcxx . . $ std/string#& Element );
131 /// check if Field exists if Current is set;
132 bool checkValuecxx . . $ Configuration#checkValue(7c222eea44a24d43). ( const stdcxx . . $ std/::stringcxx . . $ std/string#& Element );
133 /// add Field.value to current Section; sets Trying to new p.
134 bool setValuecxx . . $ Configuration#setValue(1667653f663d0d88). ( const stdcxx . . $ std/::stringcxx . . $ std/string#& Element, const stdcxx . . $ std/::stringcxx . . $ std/string#& Value );
135
136 // get checked value
137 stdcxx . . $ std/::stringcxx . . $ std/string# getValuecxx . . $ Configuration#getValue(219584694fe2b248). ( void ) const { return Elementcxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).->Valuecxx . . $ ConfElem#Value.; }
138 long getLongcxx . . $ Configuration#getLong(57a65ae535d7db84). ( void ) const { return Elementcxx . . $ Configuration#Element.->GetLongcxx . . $ ConfElem#GetLong(57a65ae535d7db84).(); }
139 double getDoublecxx . . $ Configuration#getDouble(21b6c25e127938e2). ( void ) const { return Elementcxx . . $ Configuration#Element.->GetDoublecxx . . $ ConfElem#GetDouble(21b6c25e127938e2).(); }
140 const char* getStringcxx . . $ Configuration#getString(a9f41ea0e82d88cf). ( void ) const { return Elementcxx . . $ Configuration#Element.->GetStringcxx . . $ ConfElem#GetString(a9f41ea0e82d88cf).(); }
141 // set Sect as a default
142 bool useSectioncxx . . $ Configuration#useSection(7c222eea44a24d43). ( const stdcxx . . $ std/::stringcxx . . $ std/string#& name )
143 { Sectioncxx . . $ Configuration#Section. = FindSectioncxx . . $ Configuration#FindSection(3eefb06bfae2ad5f).(name); return !Sectioncxx . . $ Configuration#Section.; }
144 }; // Configuration
145
146 #endif