diff options
author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-13 03:30:49 +0000 |
---|---|---|
committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-13 03:30:49 +0000 |
commit | 6ca64b5cf2d4c0c2698d4298e88dde274f766ac4 (patch) | |
tree | c37af6ea1ae5159b8bea55a94b120359ba9188c3 /decoder/program_options.h | |
parent | e1458e933f41a95bb5f98aeffbc15242ef7752f1 (diff) |
named_enum, itoa, cdec replace --a-b=x with --a_b=x
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@536 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/program_options.h')
-rwxr-xr-x | decoder/program_options.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/decoder/program_options.h b/decoder/program_options.h index 251f5680..87afb320 100755 --- a/decoder/program_options.h +++ b/decoder/program_options.h @@ -13,6 +13,31 @@ #include <iosfwd> +// change --opt-name=x --opt_name=x for all strings x. danger: probably the argv from int main isn't supposed to be modified? +inline int arg_minusto_underscore(char *s) { + if (!*s || *s++ != '-') return 0; + if (!*s || *s++ != '-') return 0; + int chars_replaced=0; + for(;*s;++s) { + if (*s=='=') + break; + if (*s=='-') { + *s='_'; + ++chars_replaced; + } + } + return chars_replaced; +} + +inline +int argv_minus_to_underscore(int argc, char **argv) { + int chars_replaced=0; + for (int i=1;i<argc;++i) { + chars_replaced+=arg_minusto_underscore(argv[i]); + } + return chars_replaced; +} + template <class T> boost::program_options::typed_value<T>* defaulted_value(T *v) |