CommandLineParameterGenerator.h File Reference
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <boost/tokenizer.hpp>
#include "util/CommandLineParameterProvider.h"
Go to the source code of this file.
Defines | |
#define | GENERATE_STRUCT_PARAMETER_HEAD struct Parameter { |
#define | GENERATE_STRUCT_PARAMETER_PARAM(TYPE, VARIABLE) TYPE VARIABLE; |
#define | GENERATE_STRUCT_PARAMETER_TAIL }; |
#define | CLP_CLASS_START(class_name, desc, option_name, option_desc, pd1, pd2, pd3, pd4, pd5) |
#define | CLP_CLASS_TRANSFORM_START void getParameter(Parameter& param) { |
#define | CLP_CLASS_TRANSFORM_MIDDLE |
#define | CLP_CLASS_TRANSFORM_OPTION(desc, option_type, option_variable) |
#define | CLP_CLASS_TRANSFORM_END(desc) |
#define | NAMESPACE(class_name) |
#define | CLP1(class_name, desc, option_name, option_desc, pt1, pv1, pd1) |
#define | CLP2(class_name, desc, option_name, option_desc, pt1, pv1, pd1, pt2, pv2, pd2) |
#define | CLP3(class_name, desc, option_name, option_desc, pt1, pv1, pd1, pt2, pv2, pd2, pt3, pv3, pd3) |
#define | CLP4(class_name, desc, option_name, option_desc, pt1, pv1, pd1, pt2, pv2, pd2, pt3, pv3, pd3, pt4, pv4, pd4) |
#define | CLP5(class_name, desc, option_name, option_desc, pt1, pv1, pd1, pt2, pv2, pd2, pt3, pv3, pd3, pt4, pv4, pd4, pt5, pv5, pd5) |
Define Documentation
#define CLP1 | ( | class_name, | |||
desc, | |||||
option_name, | |||||
option_desc, | |||||
pt1, | |||||
pv1, | |||||
pd1 | ) |
Value:
NAMESPACE(class_name) \ CLP_CLASS_START(class_name,desc,option_name,option_desc, pd1, "", "", "", "") \ GENERATE_STRUCT_PARAMETER_HEAD \ GENERATE_STRUCT_PARAMETER_PARAM(pt1, pv1) \ GENERATE_STRUCT_PARAMETER_TAIL \ CLP_CLASS_TRANSFORM_START \ param.pv1=pd1;\ CLP_CLASS_TRANSFORM_MIDDLE \ CLP_CLASS_TRANSFORM_OPTION(desc, pt1, pv1) \ CLP_CLASS_TRANSFORM_END(desc) \
#define CLP2 | ( | class_name, | |||
desc, | |||||
option_name, | |||||
option_desc, | |||||
pt1, | |||||
pv1, | |||||
pd1, | |||||
pt2, | |||||
pv2, | |||||
pd2 | ) |
Value:
NAMESPACE(class_name) \ CLP_CLASS_START(class_name,desc,option_name,option_desc, pd1, pd2, "", "", "") \ GENERATE_STRUCT_PARAMETER_HEAD \ GENERATE_STRUCT_PARAMETER_PARAM(pt1, pv1) \ GENERATE_STRUCT_PARAMETER_PARAM(pt2, pv2) \ GENERATE_STRUCT_PARAMETER_TAIL \ CLP_CLASS_TRANSFORM_START \ param.pv1=pd1;\ param.pv2=pd2;\ CLP_CLASS_TRANSFORM_MIDDLE \ CLP_CLASS_TRANSFORM_OPTION(desc, pt1, pv1) \ CLP_CLASS_TRANSFORM_OPTION(desc, pt2, pv2) \ CLP_CLASS_TRANSFORM_END(desc)
#define CLP3 | ( | class_name, | |||
desc, | |||||
option_name, | |||||
option_desc, | |||||
pt1, | |||||
pv1, | |||||
pd1, | |||||
pt2, | |||||
pv2, | |||||
pd2, | |||||
pt3, | |||||
pv3, | |||||
pd3 | ) |
Value:
NAMESPACE(class_name) \ CLP_CLASS_START(class_name,desc,option_name,option_desc, pd1, pd2, pd3, "", "") \ GENERATE_STRUCT_PARAMETER_HEAD \ GENERATE_STRUCT_PARAMETER_PARAM(pt1, pv1) \ GENERATE_STRUCT_PARAMETER_PARAM(pt2, pv2) \ GENERATE_STRUCT_PARAMETER_PARAM(pt3, pv3) \ GENERATE_STRUCT_PARAMETER_TAIL \ CLP_CLASS_TRANSFORM_START \ param.pv1=pd1;\ param.pv2=pd2;\ param.pv3=pd3;\ CLP_CLASS_TRANSFORM_MIDDLE \ CLP_CLASS_TRANSFORM_OPTION(desc, pt1, pv1) \ CLP_CLASS_TRANSFORM_OPTION(desc, pt2, pv2) \ CLP_CLASS_TRANSFORM_OPTION(desc, pt3, pv3) \ CLP_CLASS_TRANSFORM_END(desc)
#define CLP4 | ( | class_name, | |||
desc, | |||||
option_name, | |||||
option_desc, | |||||
pt1, | |||||
pv1, | |||||
pd1, | |||||
pt2, | |||||
pv2, | |||||
pd2, | |||||
pt3, | |||||
pv3, | |||||
pd3, | |||||
pt4, | |||||
pv4, | |||||
pd4 | ) |
Value:
NAMESPACE(class_name) \ CLP_CLASS_START(class_name,desc,option_name,option_desc, pd1, pd2, pd3, pd4, "") \ GENERATE_STRUCT_PARAMETER_HEAD \ GENERATE_STRUCT_PARAMETER_PARAM(pt1, pv1) \ GENERATE_STRUCT_PARAMETER_PARAM(pt2, pv2) \ GENERATE_STRUCT_PARAMETER_PARAM(pt3, pv3) \ GENERATE_STRUCT_PARAMETER_PARAM(pt4, pv4) \ GENERATE_STRUCT_PARAMETER_TAIL \ CLP_CLASS_TRANSFORM_START \ param.pv1=pd1;\ param.pv2=pd2;\ param.pv3=pd3;\ param.pv4=pd4;\ CLP_CLASS_TRANSFORM_MIDDLE \ CLP_CLASS_TRANSFORM_OPTION(desc, pt1, pv1) \ CLP_CLASS_TRANSFORM_OPTION(desc, pt2, pv2) \ CLP_CLASS_TRANSFORM_OPTION(desc, pt3, pv3) \ CLP_CLASS_TRANSFORM_OPTION(desc, pt4, pv4) \ CLP_CLASS_TRANSFORM_END(desc)
#define CLP5 | ( | class_name, | |||
desc, | |||||
option_name, | |||||
option_desc, | |||||
pt1, | |||||
pv1, | |||||
pd1, | |||||
pt2, | |||||
pv2, | |||||
pd2, | |||||
pt3, | |||||
pv3, | |||||
pd3, | |||||
pt4, | |||||
pv4, | |||||
pd4, | |||||
pt5, | |||||
pv5, | |||||
pd5 | ) |
Value:
NAMESPACE(class_name) \ CLP_CLASS_START(class_name,desc,option_name,option_desc, pd1, pd2, pd3, pd4, pd5) \ GENERATE_STRUCT_PARAMETER_HEAD \ GENERATE_STRUCT_PARAMETER_PARAM(pt1, pv1) \ GENERATE_STRUCT_PARAMETER_PARAM(pt2, pv2) \ GENERATE_STRUCT_PARAMETER_PARAM(pt3, pv3) \ GENERATE_STRUCT_PARAMETER_PARAM(pt4, pv4) \ GENERATE_STRUCT_PARAMETER_PARAM(pt5, pv5) \ GENERATE_STRUCT_PARAMETER_TAIL \ CLP_CLASS_TRANSFORM_START \ param.pv1=pd1;\ param.pv2=pd2;\ param.pv3=pd3;\ param.pv4=pd4;\ param.pv5=pd5;\ CLP_CLASS_TRANSFORM_MIDDLE \ CLP_CLASS_TRANSFORM_OPTION(desc, pt1, pv1) \ CLP_CLASS_TRANSFORM_OPTION(desc, pt2, pv2) \ CLP_CLASS_TRANSFORM_OPTION(desc, pt3, pv3) \ CLP_CLASS_TRANSFORM_OPTION(desc, pt4, pv4) \ CLP_CLASS_TRANSFORM_OPTION(desc, pt5, pv5) \ CLP_CLASS_TRANSFORM_END(desc)
#define CLP_CLASS_START | ( | class_name, | |||
desc, | |||||
option_name, | |||||
option_desc, | |||||
pd1, | |||||
pd2, | |||||
pd3, | |||||
pd4, | |||||
pd5 | ) |
Value:
class CLP::config::class_name {\ typedef boost::details::pool::singleton_default<class_name> class_name##__;\ bool _used;\ std::vector<std::string> ips;\ boost::program_options::options_description options;\ public: \ class_name() : _used(false), options(desc" Options") {\ options.add_options() (option_name,\ boost::program_options::value<std::vector<std::string> >(&ips)->composing(),\ option_desc); \ famouso::util::cmdline_options::instance().add(options);\ }\ struct Parameter; \ static inline class_name& instance() { \ return class_name##__::instance();\ }\ bool used() {\ bool u=_used;\ _used=true;\ return u;\ }
#define CLP_CLASS_TRANSFORM_END | ( | desc | ) |
Value:
} catch(boost::bad_lexical_cast &) { \ throw desc": invalid or incomplete arguments";\ } \ } else {\ if (used()) \ throw desc": to few command line arguments";\ }\ } catch (const char *c) {\ std::cout << c << std::endl << std::endl << options << std::endl; \ exit(0);\ }\ }\ }
#define CLP_CLASS_TRANSFORM_MIDDLE |
Value:
try {\ if ( !ips.empty() ) {\ used();\ typedef boost::tokenizer<boost::char_separator<char> > tokenizer;\ boost::char_separator<char> sep(":");\ std::string str(ips.back());\ ips.pop_back();\ tokenizer tokens(str, sep);\ tokenizer::iterator tok_iter = tokens.begin(); \ try { \
#define CLP_CLASS_TRANSFORM_OPTION | ( | desc, | |||
option_type, | |||||
option_variable | ) |
Value:
if (tok_iter!=tokens.end()) {\ param.option_variable=boost::lexical_cast<option_type>(*tok_iter); \ ++tok_iter; \ } else { \ throw desc": invalid or incomplete arguments"; \ }
#define CLP_CLASS_TRANSFORM_START void getParameter(Parameter& param) { |
#define GENERATE_STRUCT_PARAMETER_HEAD struct Parameter { |
#define GENERATE_STRUCT_PARAMETER_PARAM | ( | TYPE, | |||
VARIABLE | ) | TYPE VARIABLE; |
#define GENERATE_STRUCT_PARAMETER_TAIL }; |
#define NAMESPACE | ( | class_name | ) |
Value:
namespace CLP { \ namespace config { \ class class_name; \ } \ }