queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
BoostInputOptionsParser.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // QUESO - a library to support the Quantification of Uncertainty
5 // for Estimation, Simulation and Optimization
6 //
7 // Copyright (C) 2008-2017 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 #include <queso/config_queso.h>
25 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
26 
27 #ifndef UQ_BOOST_INPUT_OPTIONS_H
28 #define UQ_BOOST_INPUT_OPTIONS_H
29 
30 #include <string>
31 #include <queso/ScopedPtr.h>
32 #include <queso/BaseInputOptionsParser.h>
33 
34 namespace boost
35 {
36  namespace program_options
37  {
38  class options_description;
39  class variables_map;
40  }
41 }
42 
43 namespace QUESO {
44 
46 {
47 public:
49  BoostInputOptionsParser(const std::string & filename);
50 
52 
57 
59 
62  virtual ~BoostInputOptionsParser();
63 
65 
68  void scanInputFile();
69 
71 
77  template <class T>
78  void registerOption(const std::string & name,
79  const T & defaultValue,
80  const std::string & description);
81 
83  void registerOption(const std::string & name, const std::string & description);
84 
86  template <class T>
87  void getOption(const std::string & name, T & value) const;
88 
90  friend std::ostream & operator<<(std::ostream & os,
91  const BoostInputOptionsParser & parser);
92 
93 protected:
94  // Needs to be a copy, not a reference; we don't want to force users
95  // to keep their strings around and non-temporary, and we don't have
96  // a non-temporary "" string for internal use.
97  const std::string m_filename;
98 
101 
102 private:
104 };
105 
106 } // End namespace QUESO
107 
108 #endif // UQ_BOOST_INPUT_OPTIONS_H
109 
110 #endif // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
ScopedPtr< boost::program_options::options_description >::Type m_optionsDescription
BoostInputOptionsParser()
Default constructor that sets m_filename to &quot;&quot;.
void getOption(const std::string &name, T &value) const
Get option name from the parser and set value to the parsed value.
virtual ~BoostInputOptionsParser()
Destructor.
void registerOption(const std::string &name, const T &defaultValue, const std::string &description)
Call this to register an option with the parser.
void scanInputFile()
This is the method that parses the input file.
ScopedPtr< boost::program_options::variables_map >::Type m_optionsMap
friend std::ostream & operator<<(std::ostream &os, const BoostInputOptionsParser &parser)
Helpful stream operator for printing the parser state.

Generated on Tue Jun 5 2018 19:48:54 for queso-0.57.1 by  doxygen 1.8.5