queso-0.57.0
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 #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(const std::string & name,
78  const T & defaultValue,
79  const std::string & description);
80 
82  void registerOption(const std::string & name, const std::string & description);
83 
85  template <class T>
86  void getOption(const std::string & name, T & value) const;
87 
89  friend std::ostream & operator<<(std::ostream & os,
90  const BoostInputOptionsParser & parser);
91 
92 protected:
93  // Needs to be a copy, not a reference; we don't want to force users
94  // to keep their strings around and non-temporary, and we don't have
95  // a non-temporary "" string for internal use.
96  const std::string m_filename;
97 
100 
101 private:
103 };
104 
105 } // End namespace QUESO
106 
107 #endif // UQ_BOOST_INPUT_OPTIONS_H
108 
109 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
ScopedPtr< boost::program_options::options_description >::Type m_optionsDescription
void getOption(const std::string &name, T &value) const
Get option name from the parser and set value to the parsed value.
friend std::ostream & operator<<(std::ostream &os, const BoostInputOptionsParser &parser)
Helpful stream operator for printing the parser state.
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.
ScopedPtr< boost::program_options::variables_map >::Type m_optionsMap
void scanInputFile()
This is the method that parses the input file.
BoostInputOptionsParser()
Default constructor that sets m_filename to &quot;&quot;.

Generated on Sat Apr 22 2017 14:04:35 for queso-0.57.0 by  doxygen 1.8.5