queso-0.56.1
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-2015 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 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
25 
26 #ifndef UQ_BOOST_INPUT_OPTIONS_H
27 #define UQ_BOOST_INPUT_OPTIONS_H
28 
29 #include <string>
30 #include <queso/ScopedPtr.h>
31 #include <queso/BaseInputOptionsParser.h>
32 
33 namespace boost
34 {
35  namespace program_options
36  {
37  class options_description;
38  class variables_map;
39  }
40 }
41 
42 namespace QUESO {
43 
45 {
46 public:
48  BoostInputOptionsParser(const std::string & filename);
49 
51 
56 
58 
61  virtual ~BoostInputOptionsParser();
62 
64 
67  void scanInputFile();
68 
70 
76  template <class T>
77  void registerOption(std::string name, T defaultValue, std::string description);
78 
80  void registerOption(std::string name, std::string description);
81 
83  template <class T>
84  void getOption(std::string & name, T & value);
85 
87  friend std::ostream & operator<<(std::ostream & os,
88  const BoostInputOptionsParser & parser);
89 
90 protected:
91  // Needs to be a copy, not a reference; we don't want to force users
92  // to keep their strings around and non-temporary, and we don't have
93  // a non-temporary "" string for internal use.
94  const std::string m_filename;
95 
96  ScopedPtr<boost::program_options::options_description>::Type m_optionsDescription;
97  ScopedPtr<boost::program_options::variables_map>::Type m_optionsMap;
98 
99 private:
101 };
102 
103 } // End namespace QUESO
104 
105 #endif // UQ_BOOST_INPUT_OPTIONS_H
106 
107 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
ScopedPtr< boost::program_options::options_description >::Type m_optionsDescription
virtual ~BoostInputOptionsParser()
Destructor.
friend std::ostream & operator<<(std::ostream &os, const BoostInputOptionsParser &parser)
Helpful stream operator for printing the parser state.
void getOption(std::string &name, T &value)
Get option name from the parser and set value to the parsed value.
ScopedPtr< boost::program_options::variables_map >::Type m_optionsMap
BoostInputOptionsParser()
Default constructor that sets m_filename to &quot;&quot;.
void scanInputFile()
This is the method that parses the input file.
void registerOption(std::string name, T defaultValue, std::string description)
Call this to register an option with the parser.

Generated on Thu Dec 15 2016 13:23:10 for queso-0.56.1 by  doxygen 1.8.5