1 #ifndef teca_program_options_h
2 #define teca_program_options_h
6 #if defined(TECA_HAS_BOOST) && !defined(SWIG)
7 #include "teca_config.h"
12 #include <boost/array.hpp>
16 namespace program_options
18 class options_description;
23 using options_description = boost::program_options::options_description;
24 using variables_map = boost::program_options::variables_map;
29 template <
typename T,
size_t N>
30 std::istream& operator>>(std::istream& str, std::array<T,N>& arr)
32 for (
size_t i = 0; i < N; ++i)
33 str >> std::skipws >> arr[i];
39 template <
typename T,
size_t N>
40 std::istream& operator>>(std::istream& str, boost::array<T,N>& arr)
42 for (
size_t i = 0; i < N; ++i)
43 str >> std::skipws >> arr[i];
46 template <
typename T,
size_t N>
47 std::ostream&
operator<<(std::ostream& str,
const boost::array<T,N>& arr)
50 for (
size_t i = 1; i < N; ++i)
57 #define TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION() \
60 void get_properties_description(const std::string &prefix, \
61 boost::program_options::options_description &opts) override; \
64 #define TECA_SET_ALGORITHM_PROPERTIES() \
66 void set_properties(const std::string &prefix, \
67 boost::program_options::variables_map &opts) override; \
76 #define TECA_POPTS_GET(_type, _prefix, _name, _desc) \
77 (((_prefix.empty()?"":_prefix+"::") + #_name).c_str(), \
78 boost::program_options::value<_type>()->default_value \
79 (this->get_ ## _name()), "\n" _desc "\n")
81 #define TECA_POPTS_MULTI_GET(_type, _prefix, _name, _desc) \
82 (((_prefix.empty()?"":_prefix+"::") + #_name).c_str(), \
83 boost::program_options::value<_type>()->multitoken \
84 ()->default_value(this->get_ ## _name()), \
87 #define TECA_POPTS_SET(_opts, _type, _prefix, _name) \
88 {std::string opt_name = \
89 (_prefix.empty()?"":_prefix+"::") + #_name; \
90 bool defd = _opts[opt_name].defaulted(); \
93 _type val = _opts[opt_name].as<_type>(); \
94 if (this->verbose && \
95 teca_mpi_util::mpi_rank_0(this->get_communicator())) \
97 TECA_STATUS("Setting " << opt_name << " = " << val) \
99 this->set_##_name(val); \
103 #define TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
104 #define TECA_SET_ALGORITHM_PROPERTIES()
TECA_EXPORT std::ostream & operator<<(std::ostream &os, const teca_calendar_util::time_point &tpt)
send the time_point to a stream in humnan readable form