From c14c5ff23627c2671799991d65527695c625c7d8 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Fri, 27 Jun 2014 22:43:21 +0800 Subject: [PATCH] Documentation on error related files and include dependent header. --- include/rapidjson/error/en.h | 7 +++++++ include/rapidjson/error/error.h | 34 +++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/include/rapidjson/error/en.h b/include/rapidjson/error/en.h index dc6dc48..45017d3 100644 --- a/include/rapidjson/error/en.h +++ b/include/rapidjson/error/en.h @@ -5,6 +5,13 @@ namespace rapidjson { +//! Maps error code of parsing into error message. +/*! + \param parseErrorCode Error code obtained in parsing. + \return the error message. + \note User can make a copy of this function for localization. + Using switch-case is safer for future modification of error codes. +*/ inline const RAPIDJSON_ERROR_CHARTYPE* GetParseError_En(ParseErrorCode parseErrorCode) { switch (parseErrorCode) { case kParseErrorNone: return RAPIDJSON_ERROR_STRING("No error."); diff --git a/include/rapidjson/error/error.h b/include/rapidjson/error/error.h index a24178a..ba45e7e 100644 --- a/include/rapidjson/error/error.h +++ b/include/rapidjson/error/error.h @@ -1,24 +1,46 @@ #ifndef RAPIDJSON_ERROR_ERROR_H__ #define RAPIDJSON_ERROR_ERROR_H__ -// For example, on Windows, user can define this macro as TCHAR +#include "../reader.h" // ParseErrorCode + +/////////////////////////////////////////////////////////////////////////////// +// RAPIDJSON_ERROR_CHARTYPE + +//! Character type of error messages. +/*! The default charater type is char. + On Windows, user can define this macro as TCHAR for supporting both + unicode/non-unicode settings. +*/ #ifndef RAPIDJSON_ERROR_CHARTYPE #define RAPIDJSON_ERROR_CHARTYPE char #endif -// For example, on Windows, user can define this macro as _T(x) +/////////////////////////////////////////////////////////////////////////////// +// RAPIDJSON_ERROR_STRING + +//! Macro for converting string literial to RAPIDJSON_ERROR_CHARTYPE[]. +/*! By default this conversion macro does nothing. + On Windows, user can define this macro as _T(x) for supporting both + unicode/non-unicode settings. +*/ #ifndef RAPIDJSON_ERROR_STRING #define RAPIDJSON_ERROR_STRING(x) x #endif namespace rapidjson { -// User can dynamically change locale in runtime, e.g.: -// GetParseErrorFunc GetParseError = GetParseError_En; // or whatever -// const RAPIDJSON_ERROR_CHARTYPE* s = GetParseError(document.GetParseErrorCode()); +//! Function pointer type of GetParseError(). +/*! This is the prototype for GetParseError_X(), where X is a locale. + User can dynamically change locale in runtime, e.g.: + +\code + GetParseErrorFunc GetParseError = GetParseError_En; // or whatever + const RAPIDJSON_ERROR_CHARTYPE* s = GetParseError(document.GetParseErrorCode()); +\endcode +*/ typedef const RAPIDJSON_ERROR_CHARTYPE* (*GetParseErrorFunc)(ParseErrorCode); } // namespace rapidjson -#endif // RAPIDJSON_ERROR_ERROR_H__ \ No newline at end of file +#endif // RAPIDJSON_ERROR_ERROR_H__