summaryrefslogtreecommitdiff
path: root/decoder/program_options.h
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-13 03:30:49 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-13 03:30:49 +0000
commit847bfaa16c8a89f11911e1f27f5ad637b8f82723 (patch)
tree56388bd4428be4e88333f5739ba1cfc16d295f41 /decoder/program_options.h
parentb9a0af070c3af78bc71a5b9790d3758f5071a469 (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-xdecoder/program_options.h25
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)