123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- #ifndef BOOST_VARIABLES_MAP_VP_2003_05_19
- #define BOOST_VARIABLES_MAP_VP_2003_05_19
- #include <boost/program_options/config.hpp>
- #include <boost/any.hpp>
- #include <boost/shared_ptr.hpp>
- #include <string>
- #include <map>
- #include <set>
- #if defined(BOOST_MSVC)
- # pragma warning (push)
- # pragma warning (disable:4251)
- #endif
- namespace boost { namespace program_options {
- template<class charT>
- class basic_parsed_options;
- class value_semantic;
- class variables_map;
-
-
- BOOST_PROGRAM_OPTIONS_DECL
- void store(const basic_parsed_options<char>& options, variables_map& m,
- bool utf8 = false);
-
- BOOST_PROGRAM_OPTIONS_DECL
- void store(const basic_parsed_options<wchar_t>& options,
- variables_map& m);
-
- BOOST_PROGRAM_OPTIONS_DECL void notify(variables_map& m);
-
- class BOOST_PROGRAM_OPTIONS_DECL variable_value {
- public:
- variable_value() : m_defaulted(false) {}
- variable_value(const boost::any& xv, bool xdefaulted)
- : v(xv), m_defaulted(xdefaulted)
- {}
-
- template<class T>
- const T& as() const {
- return boost::any_cast<const T&>(v);
- }
-
- template<class T>
- T& as() {
- return boost::any_cast<T&>(v);
- }
-
- bool empty() const;
-
- bool defaulted() const;
-
- const boost::any& value() const;
-
- boost::any& value();
- private:
- boost::any v;
- bool m_defaulted;
-
-
-
-
-
- shared_ptr<const value_semantic> m_value_semantic;
- friend BOOST_PROGRAM_OPTIONS_DECL
- void store(const basic_parsed_options<char>& options,
- variables_map& m, bool);
- friend class BOOST_PROGRAM_OPTIONS_DECL variables_map;
- };
-
- class BOOST_PROGRAM_OPTIONS_DECL abstract_variables_map {
- public:
- abstract_variables_map();
- abstract_variables_map(const abstract_variables_map* next);
- virtual ~abstract_variables_map() {}
-
- const variable_value& operator[](const std::string& name) const;
-
- void next(abstract_variables_map* next);
- private:
-
- virtual const variable_value& get(const std::string& name) const = 0;
- const abstract_variables_map* m_next;
- };
-
- class BOOST_PROGRAM_OPTIONS_DECL variables_map : public abstract_variables_map,
- public std::map<std::string, variable_value>
- {
- public:
- variables_map();
- variables_map(const abstract_variables_map* next);
-
- const variable_value& operator[](const std::string& name) const
- { return abstract_variables_map::operator[](name); }
-
- void clear();
- void notify();
- private:
-
- const variable_value& get(const std::string& name) const;
-
- std::set<std::string> m_final;
- friend BOOST_PROGRAM_OPTIONS_DECL
- void store(const basic_parsed_options<char>& options,
- variables_map& xm,
- bool utf8);
-
- std::map<std::string, std::string> m_required;
- };
-
- inline bool
- variable_value::empty() const
- {
- return v.empty();
- }
- inline bool
- variable_value::defaulted() const
- {
- return m_defaulted;
- }
- inline
- const boost::any&
- variable_value::value() const
- {
- return v;
- }
- inline
- boost::any&
- variable_value::value()
- {
- return v;
- }
- }}
- #if defined(BOOST_MSVC)
- # pragma warning (pop)
- #endif
- #endif
|