From cd8550c29c13b09a2a147ea55f533820cdc98fb0 Mon Sep 17 00:00:00 2001 From: numatrumpet Date: Mon, 8 Sep 2014 16:59:39 +0900 Subject: [PATCH] Without using preprocessor --- tinyxml2.h | 76 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/tinyxml2.h b/tinyxml2.h index 6ef7493..0910e0e 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -480,44 +480,54 @@ public: } }; -#define FOR_EACH(F) \ - F(XML_SUCCESS) \ - F(XML_NO_ATTRIBUTE) \ - F(XML_WRONG_ATTRIBUTE_TYPE) \ - F(XML_ERROR_FILE_NOT_FOUND) \ - F(XML_ERROR_FILE_COULD_NOT_BE_OPENED) \ - F(XML_ERROR_FILE_READ_ERROR) \ - F(XML_ERROR_ELEMENT_MISMATCH) \ - F(XML_ERROR_PARSING_ELEMENT) \ - F(XML_ERROR_PARSING_ATTRIBUTE) \ - F(XML_ERROR_IDENTIFYING_TAG) \ - F(XML_ERROR_PARSING_TEXT) \ - F(XML_ERROR_PARSING_CDATA) \ - F(XML_ERROR_PARSING_COMMENT) \ - F(XML_ERROR_PARSING_DECLARATION) \ - F(XML_ERROR_PARSING_UNKNOWN) \ - F(XML_ERROR_EMPTY_DOCUMENT) \ - F(XML_ERROR_MISMATCHED_ELEMENT) \ - F(XML_ERROR_PARSING) \ - F(XML_CAN_NOT_CONVERT_TEXT) \ - F(XML_NO_TEXT_NODE) - -#define FF(X) X, enum XMLError { - FOR_EACH(FF) - XML_ERROR_ID_NUM, - XML_NO_ERROR = 0 + XML_SUCCESS = 0, + XML_NO_ERROR = 0, + XML_NO_ATTRIBUTE, + XML_WRONG_ATTRIBUTE_TYPE, + XML_ERROR_FILE_NOT_FOUND, + XML_ERROR_FILE_COULD_NOT_BE_OPENED, + XML_ERROR_FILE_READ_ERROR, + XML_ERROR_ELEMENT_MISMATCH, + XML_ERROR_PARSING_ELEMENT, + XML_ERROR_PARSING_ATTRIBUTE, + XML_ERROR_IDENTIFYING_TAG, + XML_ERROR_PARSING_TEXT, + XML_ERROR_PARSING_CDATA, + XML_ERROR_PARSING_COMMENT, + XML_ERROR_PARSING_DECLARATION, + XML_ERROR_PARSING_UNKNOWN, + XML_ERROR_EMPTY_DOCUMENT, + XML_ERROR_MISMATCHED_ELEMENT, + XML_ERROR_PARSING, + XML_CAN_NOT_CONVERT_TEXT, + XML_NO_TEXT_NODE }; -#undef FF -#define FF(X) #X, + + static const char *ErrorNames[] = { - FOR_EACH(FF) - "OUT_OF_RANGE" + "XML_SUCCESS", + "XML_NO_ATTRIBUTE", + "XML_WRONG_ATTRIBUTE_TYPE", + "XML_ERROR_FILE_NOT_FOUND", + "XML_ERROR_FILE_COULD_NOT_BE_OPENED", + "XML_ERROR_FILE_READ_ERROR", + "XML_ERROR_ELEMENT_MISMATCH", + "XML_ERROR_PARSING_ELEMENT", + "XML_ERROR_PARSING_ATTRIBUTE", + "XML_ERROR_IDENTIFYING_TAG", + "XML_ERROR_PARSING_TEXT", + "XML_ERROR_PARSING_CDATA", + "XML_ERROR_PARSING_COMMENT", + "XML_ERROR_PARSING_DECLARATION", + "XML_ERROR_PARSING_UNKNOWN", + "XML_ERROR_EMPTY_DOCUMENT", + "XML_ERROR_MISMATCHED_ELEMENT", + "XML_ERROR_PARSING", + "XML_CAN_NOT_CONVERT_TEXT", + "XML_NO_TEXT_NODE" }; -#undef FF -#undef FOR_EACH - /* Utility functionality.