From 847bfaa16c8a89f11911e1f27f5ad637b8f82723 Mon Sep 17 00:00:00 2001 From: graehl Date: Fri, 13 Aug 2010 03:30:49 +0000 Subject: 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 --- decoder/program_options.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'decoder/program_options.h') 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 +// 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 boost::program_options::typed_value* defaulted_value(T *v) -- cgit v1.2.3