File indexing completed on 2025-01-18 09:50:15
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_PARSERS_VP_2003_05_19
0008 #define BOOST_PARSERS_VP_2003_05_19
0009
0010 #include <boost/program_options/config.hpp>
0011 #include <boost/program_options/option.hpp>
0012 #include <boost/program_options/detail/cmdline.hpp>
0013
0014 #include <boost/function/function1.hpp>
0015
0016 #include <iosfwd>
0017 #include <vector>
0018 #include <utility>
0019
0020 #if defined(BOOST_MSVC)
0021 # pragma warning (push)
0022 # pragma warning (disable:4251)
0023 #endif
0024
0025 namespace boost { namespace program_options {
0026
0027 class options_description;
0028 class positional_options_description;
0029
0030
0031
0032
0033
0034
0035
0036 template<class charT>
0037 class basic_parsed_options {
0038 public:
0039 explicit basic_parsed_options(const options_description* xdescription, int options_prefix = 0)
0040 : description(xdescription), m_options_prefix(options_prefix) {}
0041
0042 std::vector< basic_option<charT> > options;
0043
0044
0045
0046
0047
0048 const options_description* description;
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 int m_options_prefix;
0060 };
0061
0062
0063
0064
0065
0066 template<>
0067 class BOOST_PROGRAM_OPTIONS_DECL basic_parsed_options<wchar_t> {
0068 public:
0069
0070 explicit basic_parsed_options(const basic_parsed_options<char>& po);
0071
0072 std::vector< basic_option<wchar_t> > options;
0073 const options_description* description;
0074
0075
0076
0077 basic_parsed_options<char> utf8_encoded_options;
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088 int m_options_prefix;
0089 };
0090
0091 typedef basic_parsed_options<char> parsed_options;
0092 typedef basic_parsed_options<wchar_t> wparsed_options;
0093
0094
0095
0096
0097
0098 typedef function1<std::pair<std::string, std::string>, const std::string&> ext_parser;
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114 template<class charT>
0115 class basic_command_line_parser : private detail::cmdline {
0116 public:
0117
0118
0119
0120 basic_command_line_parser(const std::vector<
0121 std::basic_string<charT> >& args);
0122
0123
0124
0125 basic_command_line_parser(int argc, const charT* const argv[]);
0126
0127
0128 basic_command_line_parser& options(const options_description& desc);
0129
0130 basic_command_line_parser& positional(
0131 const positional_options_description& desc);
0132
0133
0134 basic_command_line_parser& style(int);
0135
0136 basic_command_line_parser& extra_parser(ext_parser);
0137
0138
0139
0140
0141 basic_parsed_options<charT> run();
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151 basic_command_line_parser& allow_unregistered();
0152
0153 using detail::cmdline::style_parser;
0154
0155 basic_command_line_parser& extra_style_parser(style_parser s);
0156
0157 private:
0158 const options_description* m_desc;
0159 };
0160
0161 typedef basic_command_line_parser<char> command_line_parser;
0162 typedef basic_command_line_parser<wchar_t> wcommand_line_parser;
0163
0164
0165
0166
0167 template<class charT>
0168 basic_parsed_options<charT>
0169 parse_command_line(int argc, const charT* const argv[],
0170 const options_description&,
0171 int style = 0,
0172 function1<std::pair<std::string, std::string>,
0173 const std::string&> ext
0174 = ext_parser());
0175
0176
0177
0178
0179
0180 template<class charT>
0181 #if ! BOOST_WORKAROUND(__ICL, BOOST_TESTED_AT(700))
0182 BOOST_PROGRAM_OPTIONS_DECL
0183 #endif
0184 basic_parsed_options<charT>
0185 parse_config_file(std::basic_istream<charT>&, const options_description&,
0186 bool allow_unregistered = false);
0187
0188
0189
0190
0191
0192
0193 #ifdef BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS
0194 template<class charT>
0195 #else
0196 template<class charT = char>
0197 #endif
0198 #if ! BOOST_WORKAROUND(__ICL, BOOST_TESTED_AT(700))
0199 BOOST_PROGRAM_OPTIONS_DECL
0200 #endif
0201 basic_parsed_options<charT>
0202 parse_config_file(const char* filename, const options_description&,
0203 bool allow_unregistered = false);
0204
0205
0206
0207 enum collect_unrecognized_mode
0208 { include_positional, exclude_positional };
0209
0210
0211
0212
0213
0214
0215
0216 template<class charT>
0217 std::vector< std::basic_string<charT> >
0218 collect_unrecognized(const std::vector< basic_option<charT> >& options,
0219 enum collect_unrecognized_mode mode);
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230 BOOST_PROGRAM_OPTIONS_DECL parsed_options
0231 parse_environment(const options_description&,
0232 const function1<std::string, std::string>& name_mapper);
0233
0234
0235
0236
0237
0238
0239
0240 BOOST_PROGRAM_OPTIONS_DECL parsed_options
0241 parse_environment(const options_description&, const std::string& prefix);
0242
0243
0244
0245
0246
0247
0248 BOOST_PROGRAM_OPTIONS_DECL parsed_options
0249 parse_environment(const options_description&, const char* prefix);
0250
0251
0252
0253
0254
0255
0256
0257
0258 BOOST_PROGRAM_OPTIONS_DECL std::vector<std::string>
0259 split_unix(const std::string& cmdline, const std::string& seperator = " \t",
0260 const std::string& quote = "'\"", const std::string& escape = "\\");
0261
0262 #ifndef BOOST_NO_STD_WSTRING
0263
0264 BOOST_PROGRAM_OPTIONS_DECL std::vector<std::wstring>
0265 split_unix(const std::wstring& cmdline, const std::wstring& seperator = L" \t",
0266 const std::wstring& quote = L"'\"", const std::wstring& escape = L"\\");
0267 #endif
0268
0269 #ifdef _WIN32
0270
0271
0272
0273
0274
0275
0276 BOOST_PROGRAM_OPTIONS_DECL std::vector<std::string>
0277 split_winmain(const std::string& cmdline);
0278
0279 #ifndef BOOST_NO_STD_WSTRING
0280
0281 BOOST_PROGRAM_OPTIONS_DECL std::vector<std::wstring>
0282 split_winmain(const std::wstring& cmdline);
0283 #endif
0284 #endif
0285
0286
0287 }}
0288
0289 #if defined(BOOST_MSVC)
0290 # pragma warning (pop)
0291 #endif
0292
0293 #undef DECL
0294
0295 #include "boost/program_options/detail/parsers.hpp"
0296
0297 #endif