Documentation on error related files and include dependent header.
This commit is contained in:
parent
69ca7487bc
commit
c14c5ff236
@ -5,6 +5,13 @@
|
|||||||
|
|
||||||
namespace rapidjson {
|
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) {
|
inline const RAPIDJSON_ERROR_CHARTYPE* GetParseError_En(ParseErrorCode parseErrorCode) {
|
||||||
switch (parseErrorCode) {
|
switch (parseErrorCode) {
|
||||||
case kParseErrorNone: return RAPIDJSON_ERROR_STRING("No error.");
|
case kParseErrorNone: return RAPIDJSON_ERROR_STRING("No error.");
|
||||||
|
@ -1,24 +1,46 @@
|
|||||||
#ifndef RAPIDJSON_ERROR_ERROR_H__
|
#ifndef RAPIDJSON_ERROR_ERROR_H__
|
||||||
#define 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
|
#ifndef RAPIDJSON_ERROR_CHARTYPE
|
||||||
#define RAPIDJSON_ERROR_CHARTYPE char
|
#define RAPIDJSON_ERROR_CHARTYPE char
|
||||||
#endif
|
#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
|
#ifndef RAPIDJSON_ERROR_STRING
|
||||||
#define RAPIDJSON_ERROR_STRING(x) x
|
#define RAPIDJSON_ERROR_STRING(x) x
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace rapidjson {
|
namespace rapidjson {
|
||||||
|
|
||||||
// User can dynamically change locale in runtime, e.g.:
|
//! Function pointer type of GetParseError().
|
||||||
// GetParseErrorFunc GetParseError = GetParseError_En; // or whatever
|
/*! This is the prototype for GetParseError_X(), where X is a locale.
|
||||||
// const RAPIDJSON_ERROR_CHARTYPE* s = GetParseError(document.GetParseErrorCode());
|
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);
|
typedef const RAPIDJSON_ERROR_CHARTYPE* (*GetParseErrorFunc)(ParseErrorCode);
|
||||||
|
|
||||||
} // namespace rapidjson
|
} // namespace rapidjson
|
||||||
|
|
||||||
#endif // RAPIDJSON_ERROR_ERROR_H__
|
#endif // RAPIDJSON_ERROR_ERROR_H__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user