Without using preprocessor

This commit is contained in:
numatrumpet 2014-09-08 16:59:39 +09:00
parent 9f52ad5289
commit cd8550c29c
1 changed files with 43 additions and 33 deletions

View File

@ -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 { enum XMLError {
FOR_EACH(FF) XML_SUCCESS = 0,
XML_ERROR_ID_NUM, XML_NO_ERROR = 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[] = { static const char *ErrorNames[] = {
FOR_EACH(FF) "XML_SUCCESS",
"OUT_OF_RANGE" "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. Utility functionality.