[MOAB-dev] r1259 - MOAB/trunk
kraftche at mcs.anl.gov
kraftche at mcs.anl.gov
Mon Aug 27 16:07:35 CDT 2007
Author: kraftche
Date: 2007-08-27 16:07:34 -0500 (Mon, 27 Aug 2007)
New Revision: 1259
Modified:
MOAB/trunk/FileOptions.cpp
MOAB/trunk/FileOptions.hpp
Log:
add method to check which of a list of string option values is specified
Modified: MOAB/trunk/FileOptions.cpp
===================================================================
--- MOAB/trunk/FileOptions.cpp 2007-08-27 21:06:13 UTC (rev 1258)
+++ MOAB/trunk/FileOptions.cpp 2007-08-27 21:07:34 UTC (rev 1259)
@@ -191,6 +191,24 @@
return MB_ENTITY_NOT_FOUND;
}
+MBErrorCode FileOptions::match_option( const char* name,
+ const char* const* values,
+ int& index ) const
+{
+ const char* optval;
+ MBErrorCode rval = get_option( name, optval );
+ if (MB_SUCCESS != rval)
+ return rval;
+
+ for (index = 0; values[index]; ++index)
+ if (compare( optval, values[index] ))
+ return MB_SUCCESS;
+
+ index = -1;
+ return MB_FAILURE;
+}
+
+
bool FileOptions::compare( const char* name, const char* option )
{
while (!strempty(name) && toupper(*name) == toupper(*option)) {
Modified: MOAB/trunk/FileOptions.hpp
===================================================================
--- MOAB/trunk/FileOptions.hpp 2007-08-27 21:06:13 UTC (rev 1258)
+++ MOAB/trunk/FileOptions.hpp 2007-08-27 21:07:34 UTC (rev 1259)
@@ -101,7 +101,21 @@
*\return MB_SUCCESS or MB_ENTITY_NOT_FOUND
*/
MBErrorCode get_option( const char* name, std::string& value ) const;
-
+
+ /**\brief Check the string value of an option
+ *
+ * Check which of a list of possible values a string option contains.
+ *\param name The option name
+ *\param values A NULL-terminated array of C-style strings enumerating
+ * the possible option values.
+ *\param index Output: The index into <code>values</code> for the
+ * option value.
+ *\return MB_SUCCESS if matched name and value.
+ * MB_ENTITY_NOT_FOUND if the option was not specified
+ * MB_FAILURE if the option value is not in the input <code>values</code> array.
+ */
+ MBErrorCode match_option( const char* name, const char* const* values, int& index ) const;
+
/**\brief Check for option for which the value is an ID list
*
* Check for and remove an ID list option. The value is expected to
More information about the moab-dev
mailing list