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

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Thu Mar 31 14:58:10 CDT 2011


Author: kraftche
Date: 2011-03-31 14:58:10 -0500 (Thu, 31 Mar 2011)
New Revision: 4702

Added:
   MOAB/trunk/src/Types.cpp
Modified:
   MOAB/trunk/src/Core.cpp
   MOAB/trunk/src/Makefile.am
   MOAB/trunk/src/moab/Types.hpp
Log:
add static arrays for enum to string conversion for enums in Types.hpp that are not bit flags

Modified: MOAB/trunk/src/Core.cpp
===================================================================
--- MOAB/trunk/src/Core.cpp	2011-03-31 19:47:38 UTC (rev 4701)
+++ MOAB/trunk/src/Core.cpp	2011-03-31 19:58:10 UTC (rev 4702)
@@ -3250,29 +3250,9 @@
   return mError->get_last_error(info);
 }
 
-#define MB_CASE_STRING(A) case A: return #A;
 std::string Core::get_error_string(const ErrorCode code) const 
 {
-  switch (code) {
-    MB_CASE_STRING(MB_SUCCESS);
-    MB_CASE_STRING(MB_INDEX_OUT_OF_RANGE);
-    MB_CASE_STRING(MB_TYPE_OUT_OF_RANGE);
-    MB_CASE_STRING(MB_MEMORY_ALLOCATION_FAILED);
-    MB_CASE_STRING(MB_ENTITY_NOT_FOUND);
-    MB_CASE_STRING(MB_MULTIPLE_ENTITIES_FOUND);
-    MB_CASE_STRING(MB_TAG_NOT_FOUND);
-    MB_CASE_STRING(MB_FILE_DOES_NOT_EXIST);
-    MB_CASE_STRING(MB_FILE_WRITE_ERROR);
-    MB_CASE_STRING(MB_NOT_IMPLEMENTED);
-    MB_CASE_STRING(MB_ALREADY_ALLOCATED);
-    MB_CASE_STRING(MB_VARIABLE_DATA_LENGTH);
-    MB_CASE_STRING(MB_INVALID_SIZE);
-    MB_CASE_STRING(MB_UNSUPPORTED_OPERATION);
-    MB_CASE_STRING(MB_UNHANDLED_OPTION);
-    MB_CASE_STRING(MB_STRUCTURED_MESH);
-    MB_CASE_STRING(MB_FAILURE);
-    default: assert(!"unknown error code"); return "(UNKNOWN ERROR CODE)";
-  }
+  return (unsigned)code <= (unsigned)MB_FAILURE ? ErrorCodeStr[code] : "INVALID ERROR CODE";
 }
 
 void Core::print(const EntityHandle ms_handle, const char *prefix,

Modified: MOAB/trunk/src/Makefile.am
===================================================================
--- MOAB/trunk/src/Makefile.am	2011-03-31 19:47:38 UTC (rev 4701)
+++ MOAB/trunk/src/Makefile.am	2011-03-31 19:58:10 UTC (rev 4702)
@@ -114,6 +114,7 @@
   TagCompare.hpp \
   TagInfo.cpp \
   TagInfo.hpp \
+  Types.cpp \
   TypeSequenceManager.cpp \
   TypeSequenceManager.hpp \
   UnstructuredElemSeq.cpp \

Added: MOAB/trunk/src/Types.cpp
===================================================================


More information about the moab-dev mailing list