[MOAB-dev] r4354 - MOAB/trunk/tools

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Mon Dec 13 10:42:53 CST 2010


Author: kraftche
Date: 2010-12-13 10:42:52 -0600 (Mon, 13 Dec 2010)
New Revision: 4354

Added:
   MOAB/trunk/tools/test_prog_opt.cpp
Modified:
   MOAB/trunk/tools/Makefile.am
   MOAB/trunk/tools/program_opt.cpp
   MOAB/trunk/tools/program_opt.hpp
Log:
Misc enhancements to ProgOptions
  o Add new option type std::vector<int> that accepts a comma-separated
    list of integer values or integer ranges.  For example: 1,2,5-11,3
  o Allow tar-like concatenation of short options.  For example, this:
      -f -g -1.0 -t ACIS -1 -2 
    can be specified as:
      -fgt12 -1.0 ACIS
  o If '--' occurs in the argument list then all subsequent arguments
      are treated as value arguments rather than flags.  So negative
      numbers, file names beginning with a '-', etc. can be specified.
  o Allow integer values to be specified as hexadecimal or octal using
      standard C notation ('0' prefix for octal, '0x' prefix for hex)
  o If a flag is specified with both a 'cancel' option and a value
      pointer, set value to false when cancel option is encountered.
  o Add new flag 'rank_subst'.  Flag has no effect when compiled in
      serial or if option is not std::string type.  If compiled in
      parallel, any occurrence of '%' in string option/arg will be 
      replaced with the rank of the current process in MPI_COMM_WORLD.
  o Accept flags for required args (for now the only flag that makes 
      sense is rank_subst)
  o Allow optional arguments at a single location in the ordered list
      of arguments.  See addOptionalArgs and getArgs.
  o Add unit tests

This almost gets us to the point of being able to use ProgOptions to
parse the command line for mbconvert.  I think the only thing we're 
still missing is some enhancements to the 'add_cancel_option' function
-ality. Mainly the ability to cancel (clear) string options and the 
ability to specify a short version of cancel options (-a vs. -A in 
mbconvert.)







Modified: MOAB/trunk/tools/Makefile.am
===================================================================
--- MOAB/trunk/tools/Makefile.am	2010-12-11 15:13:43 UTC (rev 4353)
+++ MOAB/trunk/tools/Makefile.am	2010-12-13 16:42:52 UTC (rev 4354)
@@ -137,3 +137,13 @@
 mbtagprop_SOURCES = parse.cpp parse.hpp propagate_tags.cpp
 mbmem_SOURCES = mbmem.cpp
 parread_SOURCES = parread.cpp
+
+
+check_PROGRAMS = test_prog_opt
+
+TESTS = $(check_PROGRAMS)
+
+test_prog_opt_SOURCES = test_prog_opt.cpp
+test_prog_opt_CPPFLAGS = -I$(top_srcdir)/test $(AM_CPPFLAGS) $(CPPFLAGS)
+test_prog_opt_LDADD = libprogram_opt.la
+

Modified: MOAB/trunk/tools/program_opt.cpp
===================================================================
--- MOAB/trunk/tools/program_opt.cpp	2010-12-11 15:13:43 UTC (rev 4353)
+++ MOAB/trunk/tools/program_opt.cpp	2010-12-13 16:42:52 UTC (rev 4354)
@@ -2,14 +2,25 @@
 #include <sstream>
 #include <iomanip>
 #include <cstdlib>
+#include <list>
+#include <limits>
 
+#include <assert.h>
+#include <string.h>
+
 #include "program_opt.hpp"
+#ifdef USE_MPI
+# include "moab_mpi.h"
+#endif
 
 class ProgOpt{
 
   enum types{
     FLAG = 0,
-    INT, REAL, STRING 
+    INT, 
+    REAL, 
+    STRING, 
+    INT_VECT
   };
 
   template <typename T> 
@@ -27,6 +38,8 @@


More information about the moab-dev mailing list