EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_input.h
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ input headers
5 # Copyright (C) 2015 National Research Council Canada
6 #
7 # This file is part of EGSnrc.
8 #
9 # EGSnrc is free software: you can redistribute it and/or modify it under
10 # the terms of the GNU Affero General Public License as published by the
11 # Free Software Foundation, either version 3 of the License, or (at your
12 # option) any later version.
13 #
14 # EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
17 # more details.
18 #
19 # You should have received a copy of the GNU Affero General Public License
20 # along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
21 #
22 ###############################################################################
23 #
24 # Author: Iwan Kawrakow, 2005
25 #
26 # Contributors:
27 #
28 ###############################################################################
29 */
30 
31 
37 #ifndef EGS_INPUT_
38 #define EGS_INPUT_
39 #include "egs_libconfig.h"
40 
41 #include <string>
42 #include <vector>
43 #include <iostream>
44 using namespace std;
45 
46 
47 class EGS_InputPrivate;
48 
183 
184  EGS_InputPrivate *p;
185 
186 public:
187 
189  EGS_Input();
190 
196  EGS_Input(const EGS_Input &o);
197 
201  EGS_Input(const string &name, const string &value="");
202 
204  ~EGS_Input();
205 
207  const char *name() const;
208 
216  int setContentFromFile(const char *fname);
217 
219  int setContentFromString(string &input);
220 
225  int addContentFromFile(const char *fname);
226 
228  int addContentFromString(string &input);
229 
240  EGS_Input *takeInputItem(const string &key, bool self=true);
241 
245  EGS_Input *getInputItem(const string &key) const;
246 
248  void addInputItem(const EGS_Input &i);
249 
259  int getInput(const string &key, vector<string> &values) const;
260 
266  int getInput(const string &key, vector<EGS_Float> &values) const;
267 
273  int getInput(const string &key, vector<int> &values) const;
274 
284  int getInput(const string &key, string &value) const;
285 
291  int getInput(const string &key, float &value) const;
292 
298  int getInput(const string &key, double &value) const;
299 
305  int getInput(const string &key, int &value) const;
306 
312  int getInput(const string &key, EGS_I64 &value) const;
313 
323  int getInput(const string &key, const vector<string> &allowed,
324  int def=0, bool *found=0) const;
325 
327  bool isA(const string &key) const;
328 
334  static bool compare(const string &s1, const string &s2);
335 
337  void print(int nind, ostream &);
338 
339 };
340 
341 #endif
342 
343 
#define EGS_EXPORT
Export symbols from the egspp library.
Definition: egs_libconfig.h:90
A class for storing information in a tree-like structure of key-value pairs. This class is used throu...
Definition: egs_input.h:182
Defines the EGS_EXPORT and EGS_LOCAL macros.