[MOAB-dev] r4342 - in MOAB/trunk/src: . io moab

tautges at mcs.anl.gov tautges at mcs.anl.gov
Thu Dec 9 13:41:48 CST 2010


Author: tautges
Date: 2010-12-09 13:41:48 -0600 (Thu, 09 Dec 2010)
New Revision: 4342

Modified:
   MOAB/trunk/src/FileOptions.cpp
   MOAB/trunk/src/FileOptions.hpp
   MOAB/trunk/src/io/ReadNC.cpp
   MOAB/trunk/src/io/ReadNC.hpp
   MOAB/trunk/src/moab/Range.hpp
Log:
FileOptions: added get_strs_option, debugged get_[ints,reals]_option, and 
  added a test for these functions
Range: added get_num_subranges function
ReadNC: added support for variables, including partial read of 
  timesteps/variables (see metadata_info document for details)



Modified: MOAB/trunk/src/FileOptions.cpp
===================================================================
--- MOAB/trunk/src/FileOptions.cpp	2010-12-09 16:22:21 UTC (rev 4341)
+++ MOAB/trunk/src/FileOptions.cpp	2010-12-09 19:41:48 UTC (rev 4342)
@@ -182,11 +182,11 @@
     char* endptr;
     long int sval = strtol( s, &endptr, 0 );
 
-#define EATSPACE(a) while ((!strcmp(a, " ") || \
-          !strcmp(a, ",")) && !strempty(a)) a++;
+#define EATSPACE(a) while ((*a == ' ' ||          \
+                            *a == ',') && !strempty(a)) a++;
     EATSPACE(endptr);
     long int eval = sval;
-    if (!strcmp(endptr, "-")) {
+    if (*endptr == '-') {
       endptr++;
       s = endptr;
       eval = strtol(s, &endptr, 0);
@@ -227,8 +227,6 @@
     char* endptr;
     double sval = strtod( s, &endptr);
 
-#define EATSPACE(a) while ((!strcmp(a, " ") || \
-          !strcmp(a, ",")) && !strempty(a)) a++;
     EATSPACE(endptr);
     values.push_back(sval);
 
@@ -258,6 +256,28 @@
   return MB_SUCCESS;
 }
 
+ErrorCode FileOptions::get_strs_option( const char* name, 
+                                        std::vector<std::string>& values) const
+{
+  const char* s;
+  ErrorCode rval = get_option( name, s );
+  if (MB_SUCCESS != rval)
+    return rval;
+  
+    // empty string
+  if (strempty(s))
+    return MB_TYPE_OUT_OF_RANGE;
+  
+    // parse values
+  char separator[3] = { ' ', ',', '\0' };
+  char *tmp_str = strdup(s);
+  for (char* i = strtok( tmp_str, separator ); i; i = strtok( 0, separator )) 
+    if (!strempty(i)) // skip empty strings
+      values.push_back( std::string(i));
+  


More information about the moab-dev mailing list