00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00037 #ifndef _OSRTJSON_H_
00038 #define _OSRTJSON_H_
00039
00040 #include "rtxsrc/osMacros.h"
00041 #include "rtxsrc/osSysTypes.h"
00042 #include "rtxsrc/rtxCommon.h"
00043 #include "rtxsrc/rtxError.h"
00044 #include "rtxsrc/rtxBuffer.h"
00045 #include "rtxsrc/rtxMemory.h"
00046
00047 #include "rtjsonsrc/rtJsonExternDefs.h"
00048
00049 #ifndef EXTERNJSON
00050 #ifdef BUILDJSONDLL
00051 #define EXTERNJSON __declspec(dllexport)
00052 #elif defined (USEJSONLDLL)
00053 #define EXTERNJSON __declspec(dllimport)
00054 #else
00055 #define EXTERNJSON
00056 #endif
00057 #endif
00058
00059 #ifdef __cplusplus
00060 extern "C" {
00061 #endif
00062
00063 typedef enum
00064 {
00065 OSJSONNOCOMMA,
00066 OSJSONNORMAL,
00067 OSJSONSEQOF
00068 } OSJSONState;
00069
00070
00071
00072 #define OSJSONATTR 0x00008000
00073
00074
00075
00076 #define OSJSONPUTCOMMA(pctxt) \
00077 if ((pctxt)->lastChar != '{' && (pctxt)->lastChar != ',' \
00078 && (pctxt)->lastChar != '\0' && (pctxt)->lastChar != '[') \
00079 OSRTSAFEPUTCHAR (pctxt, ',');
00080
00081 extern const signed char decodeTable[];
00082 #define BASE64TOINT(c) ((((unsigned)(c)) < 128) ? decodeTable [(c) - 40] : -1)
00083
00084
00085
00086 #ifndef DEFAULT_DOUBLE_PRECISION
00087 #define DEFAULT_DOUBLE_PRECISION 11
00088 #endif
00089
00090 #ifndef DEFAULT_FLOAT_PRECISION
00091 #define DEFAULT_FLOAT_PRECISION 6
00092 #endif
00093
00094 #ifndef OSUPCASE
00095
00096 #define OSUPCASE 0x00008000
00097 #endif
00098
00099
00100
00101
00117 EXTERNJSON int rtJsonEncAnyAttr (OSCTXT* pctxt, const OSRTDList* pvalue);
00118
00128 EXTERNJSON int rtJsonEncIntValue (OSCTXT* pctxt, OSINT32 value);
00129
00140 EXTERNJSON int rtJsonEncInt64Value (OSCTXT* pctxt, OSINT64 value);
00141
00152 EXTERNJSON int rtJsonEncBase64StrValue (OSCTXT* pctxt, OSUINT32 nocts,
00153 const OSOCTET* value);
00154
00164 EXTERNJSON int rtJsonEncBoolValue (OSCTXT* pctxt, OSBOOL value);
00165
00176 EXTERNJSON int rtJsonEncGYear (OSCTXT* pctxt, const OSXSDDateTime* pvalue);
00177
00188 EXTERNJSON int rtJsonEncGYearMonth (OSCTXT* pctxt, const OSXSDDateTime* pvalue);
00189
00200 EXTERNJSON int rtJsonEncGMonth (OSCTXT* pctxt, const OSXSDDateTime* pvalue);
00201
00212 EXTERNJSON int rtJsonEncGMonthDay (OSCTXT* pctxt, const OSXSDDateTime* pvalue);
00213
00224 EXTERNJSON int rtJsonEncGDay (OSCTXT* pctxt, const OSXSDDateTime* pvalue);
00225
00238 EXTERNJSON int rtJsonEncDate (OSCTXT* pctxt, const OSXSDDateTime* pvalue);
00239
00251 EXTERNJSON int rtJsonEncTime (OSCTXT* pctxt, const OSXSDDateTime* pvalue);
00252
00263 EXTERNJSON int rtJsonEncDateTime (OSCTXT* pctxt, const OSXSDDateTime* pvalue);
00264
00275 EXTERNJSON int rtJsonEncDecimalValue (OSCTXT* pctxt, OSREAL value,
00276 const OSDecimalFmt* pFmtSpec);
00277
00288 EXTERNJSON int rtJsonEncDoubleValue (OSCTXT* pctxt, OSREAL value,
00289 const OSDoubleFmt* pFmtSpec);
00290
00301 EXTERNJSON int rtJsonEncFloatValue (OSCTXT* pctxt, OSREAL value,
00302 const OSDoubleFmt* pFmtSpec);
00303
00314 EXTERNJSON int rtJsonEncHexStr (OSCTXT* pctxt, OSSIZE nocts,
00315 const OSOCTET* data);
00316
00327 EXTERNJSON int rtJsonEncBitStrValue (OSCTXT* pctxt, OSUINT32 nbits,
00328 const OSOCTET* data);
00339 EXTERNJSON int rtJsonEncIndent (OSCTXT* pctxt);
00340
00351 EXTERNJSON int rtJsonEncStringObject (OSCTXT* pctxt,
00352 const OSUTF8CHAR* name, const OSUTF8CHAR* value);
00353
00366 EXTERNJSON int rtJsonEncStringObject2 (OSCTXT* pctxt,
00367 const OSUTF8CHAR* name, size_t nameLen,
00368 const OSUTF8CHAR* value, size_t valueLen);
00369
00380 EXTERNJSON int rtJsonEncStringPair (OSCTXT* pctxt,
00381 const OSUTF8CHAR* name, const OSUTF8CHAR* value);
00382
00395 EXTERNJSON int rtJsonEncStringPair2 (OSCTXT* pctxt,
00396 const OSUTF8CHAR* name, size_t nameLen,
00397 const OSUTF8CHAR* value, size_t valueLen);
00398
00408 EXTERNJSON int rtJsonEncStringValue (OSCTXT* pctxt, const OSUTF8CHAR* value);
00409
00420 EXTERNJSON int rtJsonEncStringValue2 (OSCTXT* pctxt,
00421 const OSUTF8CHAR* value, size_t valueLen);
00422
00431 EXTERNJSON int rtJsonEncStringNull(OSCTXT* pctxt);
00432
00442 EXTERNJSON int rtJsonEncStringRaw(OSCTXT* pctxt, const OSUTF8CHAR* value);
00443
00454 EXTERNJSON int rtJsonEncUnicodeData (OSCTXT* pctxt, const OSUNICHAR* value,
00455 OSSIZE nchars);
00456
00467 EXTERNJSON int rtJsonEncUCS4Data (OSCTXT* pctxt, const OS32BITCHAR* value,
00468 OSSIZE nchars);
00469
00470
00480 EXTERNJSON int rtJsonEncUIntValue (OSCTXT* pctxt, OSUINT32 value);
00481
00493 EXTERNJSON int rtJsonEncUInt64Value (OSCTXT* pctxt, OSUINT64 value);
00494
00505 EXTERNJSON int rtJsonEncStartObject(OSCTXT* pctxt, const OSUTF8CHAR* name,
00506 OSBOOL noComma);
00507
00516 EXTERNJSON int rtJsonEncEndObject(OSCTXT* pctxt);
00517
00526 EXTERNJSON int rtJsonEncBetweenObject(OSCTXT* pctxt);
00527
00552 EXTERNJSON int rtJsonDecAnyElem (OSCTXT* pctxt, OSUTF8CHAR** ppvalue);
00553
00569 EXTERNJSON int rtJsonDecAnyElem2 (OSCTXT* pctxt, OSUTF8CHAR** ppvalue);
00570
00586 EXTERNJSON int rtJsonDecAnyType (OSCTXT* pctxt, OSUTF8CHAR** ppvalue);
00587
00611 EXTERNJSON int rtJsonDecBase64Str (OSCTXT* pctxt,
00612 OSOCTET* pvalue, OSUINT32* pnocts,
00613 size_t bufsize);
00614
00631 EXTERNJSON int rtJsonDecDynBase64Str (OSCTXT* pctxt, OSDynOctStr* pvalue);
00632
00643 EXTERNJSON int rtJsonDecBool (OSCTXT* pctxt, OSBOOL* pvalue);
00644
00657 EXTERNJSON int rtJsonDecDate (OSCTXT* pctxt, OSXSDDateTime* pvalue);
00658
00677 EXTERNJSON int rtJsonDecTime (OSCTXT* pctxt, OSXSDDateTime* pvalue);
00678
00691 EXTERNJSON int rtJsonDecDateTime (OSCTXT* pctxt, OSXSDDateTime* pvalue);
00692
00705 EXTERNJSON int rtJsonDecGYear (OSCTXT* pctxt, OSXSDDateTime* pvalue);
00706
00719 EXTERNJSON int rtJsonDecGYearMonth (OSCTXT* pctxt, OSXSDDateTime* pvalue);
00720
00733 EXTERNJSON int rtJsonDecGMonth (OSCTXT* pctxt, OSXSDDateTime* pvalue);
00734
00747 EXTERNJSON int rtJsonDecGMonthDay (OSCTXT* pctxt, OSXSDDateTime* pvalue);
00748
00761 EXTERNJSON int rtJsonDecGDay (OSCTXT* pctxt, OSXSDDateTime* pvalue);
00762
00777 EXTERNJSON int rtJsonDecDecimal (OSCTXT* pctxt, OSREAL* pvalue,
00778 int totalDigits, int fractionDigits);
00779
00792 EXTERNJSON int rtJsonDecDouble (OSCTXT* pctxt, OSREAL* pvalue);
00793
00818 EXTERNJSON int rtJsonDecHexStr (OSCTXT* pctxt, OSOCTET* pvalue,
00819 OSUINT32* pnocts, size_t bufsize);
00820
00838 EXTERNJSON int rtJsonDecDynHexStr (OSCTXT* pctxt, OSDynOctStr* pvalue);
00839
00853 EXTERNJSON int rtJsonDecDynBitStr
00854 (OSCTXT* pctxt, OSUINT32 *nbits, OSOCTET **data);
00855
00870 EXTERNJSON int rtJsonDecBitStrValue
00871 (OSCTXT* pctxt, OSUINT32 *nbits, OSOCTET *data, OSSIZE bufsize);
00872
00886 EXTERNJSON int rtJsonDecInt8Value (OSCTXT* pctxt, OSINT8* pvalue);
00887
00900 EXTERNJSON int rtJsonDecInt16Value (OSCTXT* pctxt, OSINT16* pvalue);
00901
00914 EXTERNJSON int rtJsonDecInt32Value (OSCTXT* pctxt, OSINT32* pvalue);
00915 #define rtJsonDecIntValue rtJsonDecInt32Value
00916
00929 EXTERNJSON int rtJsonDecInt64Value (OSCTXT* pctxt, OSINT64* pvalue);
00930
00944 EXTERNJSON int rtJsonDecUInt8Value (OSCTXT* pctxt, OSUINT8* pvalue);
00945
00958 EXTERNJSON int rtJsonDecUInt16Value (OSCTXT* pctxt, OSUINT16* pvalue);
00959
00972 EXTERNJSON int rtJsonDecUInt32Value (OSCTXT* pctxt, OSUINT32* pvalue);
00973 #define rtJsonDecUIntValue rtJsonDecUInt32Value
00974
00987 EXTERNJSON int rtJsonDecUInt64Value (OSCTXT* pctxt, OSUINT64* pvalue);
00988
00998 EXTERNJSON int rtJsonDecMatchChar (OSCTXT* pctxt, OSUTF8CHAR ch);
00999
01012 EXTERNJSON int rtJsonDecMatchObjectStart
01013 (OSCTXT* pctxt, const OSUTF8NameAndLen* nameArray, size_t numNames);
01014
01027 EXTERNJSON int rtJsonDecMatchToken (OSCTXT* pctxt, const OSUTF8CHAR* token);
01028
01042 EXTERNJSON int rtJsonDecMatchToken2
01043 (OSCTXT* pctxt, const OSUTF8CHAR* token, size_t tokenLen);
01044
01055 EXTERNJSON int rtJsonDecNameValuePair (OSCTXT* pctxt, OSUTF8NVP* pvalue);
01056
01068 EXTERNJSON int rtJsonDecNumberString (OSCTXT* pctxt, char** ppCharStr);
01069
01079 EXTERNJSON int rtJsonDecPeekChar (OSCTXT* pctxt, OSUTF8CHAR* pch);
01080
01088 EXTERNJSON char rtJsonDecPeekChar2 (OSCTXT* pctxt);
01089
01105 EXTERNJSON int rtJsonDecStringObject
01106 (OSCTXT* pctxt, const OSUTF8CHAR* name, OSUTF8CHAR** ppvalue);
01107
01122 EXTERNJSON int rtJsonDecStringValue (OSCTXT* pctxt, OSUTF8CHAR** ppvalue);
01123
01140 EXTERNJSON int rtJsonDecXmlStringValue (OSCTXT* pctxt, OSXMLSTRING* pvalue);
01141
01155 EXTERNJSON int rtJsonDecUCS2String (OSCTXT *pctxt, OSUNICHAR **ppstr,
01156 OSSIZE *pnchars);
01157
01171 EXTERNJSON int rtJsonDecUCS4String (OSCTXT *pctxt, OS32BITCHAR **ppstr,
01172 OSSIZE *pnchars);
01173
01174 EXTERNJSON int rtJsonDecSkipWhitespace (OSCTXT* pctxt);
01175
01187 EXTERNJSON size_t rtJsonGetElemIdx
01188 (OSCTXT* pctxt, const OSUTF8NameAndLen nameArray[], size_t nrows);
01189
01195 #ifdef __cplusplus
01196 }
01197 #endif
01198
01199 #endif