00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00028
00029
00030
00031
00032 extern "C"
00033 {
00034 struct _xmlNode;
00035 struct _xmlDoc;
00036 }
00037
00038 namespace LLRP
00039 {
00040 class CXMLTextEncoder;
00041 class CXMLTextEncoderStream;
00042 class CXMLTextDecoder;
00043 class CXMLTextDecoderStream;
00044
00045 class CXMLTextEncoder : public CEncoder
00046 {
00047 friend class CXMLTextEncoderStream;
00048
00049 private:
00050 char * m_pBuffer;
00051 int m_nBuffer;
00052 int m_iNext;
00053
00054 public:
00055 int m_bOverflow;
00056
00057 public:
00058 CXMLTextEncoder (
00059 char * pBuffer,
00060 int nBuffer);
00061
00062 ~CXMLTextEncoder (void);
00063
00064 void
00065 encodeElement (
00066 const CElement * pElement);
00067 };
00068
00069 class CXMLTextDecoder : public CDecoder
00070 {
00071 friend class CXMLTextDecoderStream;
00072
00073 private:
00074 struct _xmlDoc * m_pDoc;
00075 struct _xmlNode * m_pxmlNodeTree;
00076
00077 public:
00078 CXMLTextDecoder (
00079 const CTypeRegistry * pTypeRegistry,
00080 char * pBuffer,
00081 int nBuffer);
00082
00083 CXMLTextDecoder (
00084 const CTypeRegistry * pTypeRegistry,
00085 struct _xmlNode * pNodeTree);
00086
00087
00088 CXMLTextDecoder (
00089 const CTypeRegistry * pTypeRegistry,
00090 char * fname);
00091
00092 ~CXMLTextDecoder (void);
00093
00094 CMessage *
00095 decodeMessage (void);
00096
00097 };
00098
00099 class CXMLTextEncoderStream : public CEncoderStream
00100 {
00101 friend class CXMLTextEncoder;
00102
00103 public:
00104 void
00105 putRequiredSubParameter (
00106 const CParameter * pParameter,
00107 const CTypeDescriptor * pRefType);
00108
00109 void
00110 putOptionalSubParameter (
00111 const CParameter * pParameter,
00112 const CTypeDescriptor * pRefType);
00113
00114 void
00115 putRequiredSubParameterList (
00116 const tListOfParameters * pParameterList,
00117 const CTypeDescriptor * pRefType);
00118
00119 void
00120 putOptionalSubParameterList (
00121 const tListOfParameters * pParameterList,
00122 const CTypeDescriptor * pRefType);
00123
00124
00125
00126
00127
00128 void
00129 put_u8 (
00130 llrp_u8_t Value,
00131 const CFieldDescriptor * pFieldDescriptor);
00132
00133 void
00134 put_s8 (
00135 llrp_s8_t Value,
00136 const CFieldDescriptor * pFieldDescriptor);
00137
00138 void
00139 put_u8v (
00140 llrp_u8v_t Value,
00141 const CFieldDescriptor * pFieldDescriptor);
00142
00143 void
00144 put_s8v (
00145 llrp_s8v_t Value,
00146 const CFieldDescriptor * pFieldDescriptor);
00147
00148
00149
00150
00151
00152 void
00153 put_u16 (
00154 llrp_u16_t Value,
00155 const CFieldDescriptor * pFieldDescriptor);
00156
00157 void
00158 put_s16 (
00159 llrp_s16_t Value,
00160 const CFieldDescriptor * pFieldDescriptor);
00161
00162 void
00163 put_u16v (
00164 llrp_u16v_t Value,
00165 const CFieldDescriptor * pFieldDescriptor);
00166
00167 void
00168 put_s16v (
00169 llrp_s16v_t Value,
00170 const CFieldDescriptor * pFieldDescriptor);
00171
00172
00173
00174
00175
00176 void
00177 put_u32 (
00178 llrp_u32_t Value,
00179 const CFieldDescriptor * pFieldDescriptor);
00180
00181 void
00182 put_s32 (
00183 llrp_s32_t Value,
00184 const CFieldDescriptor * pFieldDescriptor);
00185
00186 void
00187 put_u32v (
00188 llrp_u32v_t Value,
00189 const CFieldDescriptor * pFieldDescriptor);
00190
00191 void
00192 put_s32v (
00193 llrp_s32v_t Value,
00194 const CFieldDescriptor * pFieldDescriptor);
00195
00196
00197
00198
00199
00200 void
00201 put_u64 (
00202 llrp_u64_t Value,
00203 const CFieldDescriptor * pFieldDescriptor);
00204
00205 void
00206 put_s64 (
00207 llrp_s64_t Value,
00208 const CFieldDescriptor * pFieldDescriptor);
00209
00210 void
00211 put_u64v (
00212 llrp_u64v_t Value,
00213 const CFieldDescriptor * pFieldDescriptor);
00214
00215 void
00216 put_s64v (
00217 llrp_s64v_t Value,
00218 const CFieldDescriptor * pFieldDescriptor);
00219
00220
00221
00222
00223
00224 void
00225 put_u1 (
00226 llrp_u1_t Value,
00227 const CFieldDescriptor * pFieldDescriptor);
00228
00229 void
00230 put_u1v (
00231 llrp_u1v_t Value,
00232 const CFieldDescriptor * pFieldDescriptor);
00233
00234 void
00235 put_u2 (
00236 llrp_u2_t Value,
00237 const CFieldDescriptor * pFieldDescriptor);
00238
00239 void
00240 put_u96 (
00241 llrp_u96_t Value,
00242 const CFieldDescriptor * pFieldDescriptor);
00243
00244 void
00245 put_utf8v (
00246 llrp_utf8v_t Value,
00247 const CFieldDescriptor * pFieldDescriptor);
00248
00249 void
00250 put_bytesToEnd (
00251 llrp_bytesToEnd_t Value,
00252 const CFieldDescriptor * pFieldDescriptor);
00253
00254
00255
00256
00257
00258 void
00259 put_e1 (
00260 int eValue,
00261 const CFieldDescriptor * pFieldDescriptor);
00262
00263 void
00264 put_e2 (
00265 int eValue,
00266 const CFieldDescriptor * pFieldDescriptor);
00267
00268 void
00269 put_e8 (
00270 int eValue,
00271 const CFieldDescriptor * pFieldDescriptor);
00272
00273 void
00274 put_e16 (
00275 int eValue,
00276 const CFieldDescriptor * pFieldDescriptor);
00277
00278 void
00279 put_e32 (
00280 int eValue,
00281 const CFieldDescriptor * pFieldDescriptor);
00282
00283 void
00284 put_e8v (
00285 llrp_u8v_t Value,
00286 const CFieldDescriptor * pFieldDescriptor);
00287
00288
00289
00290
00291
00292 void
00293 put_reserved (
00294 unsigned int nBits);
00295
00296 private:
00297 CXMLTextEncoderStream (
00298 CXMLTextEncoder * pEncoder);
00299
00300 CXMLTextEncoderStream (
00301 CXMLTextEncoderStream * pEnclosingEncoderStream);
00302
00303 CXMLTextEncoder * m_pEncoder;
00304 CXMLTextEncoderStream * m_pEnclosingEncoderStream;
00305 const CTypeDescriptor * m_pRefType;
00306 unsigned int m_nDepth;
00307
00308 void
00309 putElement (
00310 const CElement * pElement);
00311
00312 void
00313 put_enum (
00314 int eValue,
00315 const CFieldDescriptor * pFieldDescriptor);
00316
00317 void
00318 indent(int delta = 0);
00319
00320 void
00321 appendOpenTag (
00322 const char * pName);
00323
00324 void
00325 appendCloseTag (
00326 const char * pName);
00327
00328 void
00329 appendPrefixedTagName (
00330 const char * pName);
00331
00332 void
00333 appendFormat (
00334 char * pFmtStr,
00335 ...);
00336
00337 };
00338
00339 class CXMLTextDecoderStream : public CDecoderStream
00340 {
00341 friend class CXMLTextDecoder;
00342
00343 private:
00344 CXMLTextDecoderStream (
00345 CXMLTextDecoder * pDecoder);
00346
00347 CXMLTextDecoderStream (
00348 CXMLTextDecoderStream * pEnclosingDecoderStream);
00349
00350 public:
00351
00352 CElement *
00353 decodeElement (
00354 int bAllowMessage,
00355 int bSkipBlanks);
00356
00357
00358
00359
00361 llrp_u8_t
00362 get_u8 (
00363 const CFieldDescriptor * pFieldDesc);
00364
00366 llrp_s8_t
00367 get_s8 (
00368 const CFieldDescriptor * pFieldDesc);
00369
00371 llrp_u8v_t
00372 get_u8v (
00373 const CFieldDescriptor * pFieldDesc);
00374
00376 llrp_s8v_t
00377 get_s8v (
00378 const CFieldDescriptor * pFieldDesc);
00379
00380
00381
00382
00383
00385 llrp_u16_t
00386 get_u16 (
00387 const CFieldDescriptor * pFieldDesc);
00388
00390 llrp_s16_t
00391 get_s16 (
00392 const CFieldDescriptor * pFieldDesc);
00393
00395 llrp_u16v_t
00396 get_u16v (
00397 const CFieldDescriptor * pFieldDesc);
00398
00400 llrp_s16v_t
00401 get_s16v (
00402 const CFieldDescriptor * pFieldDesc);
00403
00404
00405
00406
00407
00409 llrp_u32_t
00410 get_u32 (
00411 const CFieldDescriptor * pFieldDesc);
00412
00414 llrp_s32_t
00415 get_s32 (
00416 const CFieldDescriptor * pFieldDesc);
00417
00419 llrp_u32v_t
00420 get_u32v (
00421 const CFieldDescriptor * pFieldDesc);
00422
00424 llrp_s32v_t
00425 get_s32v (
00426 const CFieldDescriptor * pFieldDesc);
00427
00428
00429
00430
00431
00433 llrp_u64_t
00434 get_u64 (
00435 const CFieldDescriptor * pFieldDesc);
00436
00438 llrp_s64_t
00439 get_s64 (
00440 const CFieldDescriptor * pFieldDesc);
00441
00443 llrp_u64v_t
00444 get_u64v (
00445 const CFieldDescriptor * pFieldDesc);
00446
00448 llrp_s64v_t
00449 get_s64v (
00450 const CFieldDescriptor * pFieldDesc);
00451
00452
00453
00454
00455
00457 llrp_u1_t
00458 get_u1 (
00459 const CFieldDescriptor * pFieldDesc);
00460
00462 llrp_u1v_t
00463 get_u1v (
00464 const CFieldDescriptor * pFieldDesc);
00465
00467 llrp_u2_t
00468 get_u2 (
00469 const CFieldDescriptor * pFieldDesc);
00470
00472 llrp_u96_t
00473 get_u96 (
00474 const CFieldDescriptor * pFieldDesc);
00475
00477 llrp_utf8v_t
00478 get_utf8v (
00479 const CFieldDescriptor * pFieldDesc);
00480
00482 llrp_bytesToEnd_t
00483 get_bytesToEnd (
00484 const CFieldDescriptor * pFieldDesc);
00485
00486
00487
00488
00489
00491 int
00492 get_e1 (
00493 const CFieldDescriptor * pFieldDesc);
00494
00496 int
00497 get_e2 (
00498 const CFieldDescriptor * pFieldDesc);
00499
00501 int
00502 get_e8 (
00503 const CFieldDescriptor * pFieldDesc);
00504
00506 int
00507 get_e16 (
00508 const CFieldDescriptor * pFieldDesc);
00509
00511 int
00512 get_e32 (
00513 const CFieldDescriptor * pFieldDesc);
00514
00516 llrp_u8v_t
00517 get_e8v (
00518 const CFieldDescriptor * pFieldDesc);
00519
00520
00521
00522
00523
00524 void
00525 get_reserved (
00526 unsigned int nBits);
00527
00528 private:
00529 CXMLTextDecoder * m_pDecoder;
00530 CXMLTextDecoderStream * m_pEnclosingDecoderStream;
00531 const CTypeDescriptor * m_pRefType;
00532 struct _xmlNode * m_pTargetNode;
00533 struct _xmlNode * m_pCurrentChildNode;
00534 struct _xmlNode * m_pLastFieldNode;
00535
00536 llrp_bool_t
00537 verifyVectorAllocation (
00538 const void * pValue,
00539 const CFieldDescriptor * pFieldDescriptor);
00540
00541 static int
00542 isInsignificantNode (
00543 struct _xmlNode * pnode);
00544
00545
00546 int
00547 getFieldStringPtr(
00548 const CFieldDescriptor * pFieldDescriptor,
00549 const llrp_u8_t ** pbuf,
00550 const llrp_u8_t ** pend);
00551
00552 llrp_s64v_t
00553 getSpacedVectorField (
00554 const CFieldDescriptor * pFieldDescriptor,
00555 llrp_s64_t minValue,
00556 llrp_s64_t maxValue);
00557
00558 llrp_s64v_t
00559 getFixedVectorField (
00560 const CFieldDescriptor * pFieldDescriptor,
00561 unsigned int vectorSize,
00562 llrp_s64_t minValue,
00563 llrp_s64_t maxValue);
00564
00565 llrp_s64_t
00566 getIntegerField (
00567 const CFieldDescriptor * pFieldDescriptor,
00568 llrp_s64_t minValue,
00569 llrp_s64_t maxValue);
00570
00571 llrp_s64_t getInteger(
00572 const CFieldDescriptor * pFieldDescriptor,
00573 const llrp_u8_t * pbuf,
00574 const llrp_u8_t * pend,
00575 CErrorDetails *pError,
00576 llrp_s64_t minValue,
00577 llrp_s64_t maxValue);
00578
00579
00580
00581 static const llrp_u8_t *
00582 getSingleU1(
00583 const llrp_u8_t * pbuf,
00584 const llrp_u8_t * pend,
00585 llrp_s64_t * pValue);
00586
00587 static const llrp_u8_t *
00588 getSingleEnum(
00589 const CFieldDescriptor * pFieldDescriptor,
00590 const llrp_u8_t * pbuf,
00591 const llrp_u8_t * pend,
00592 llrp_s64_t * pValue);
00593
00594 static const llrp_u8_t *
00595 getSingleDecimal(
00596 const llrp_u8_t * pbuf,
00597 const llrp_u8_t * pend,
00598 llrp_s64_t * pValue);
00599
00600 static const llrp_u8_t *
00601 getSingleHexidecimal(
00602 const llrp_u8_t * pbuf,
00603 const llrp_u8_t * pend,
00604 llrp_s64_t * pValue);
00605
00606 static int
00607 cleanString(
00608 const llrp_u8_t ** ppbuf,
00609 const llrp_u8_t ** ppend);
00610
00611 static const llrp_u8_t *
00612 getSingleTimestamp(
00613 const llrp_u8_t * pbuf,
00614 const llrp_u8_t * pend,
00615 llrp_s64_t * pValue);
00616
00617 static llrp_u16_t
00618 countElements(
00619 const char * pval,
00620 int nval);
00621
00622 private:
00623 static const llrp_s64_t MAX_U8 = ((1ull << 8u) - 1u);
00624 static const llrp_s64_t MIN_U8 = 0ull;
00625 static const llrp_s64_t MAX_S8 = ((1ull << 7u) - 1u);
00626 static const llrp_s64_t MIN_S8 = (-1ll - MAX_S8);
00627
00628 static const llrp_s64_t MAX_U16 = ((1ull << 16u) - 1u);
00629 static const llrp_s64_t MIN_U16 = 0ull;
00630 static const llrp_s64_t MAX_S16 = ((1ull << 15u) - 1u);
00631 static const llrp_s64_t MIN_S16 = (-1ll - MAX_S16);
00632
00633 static const llrp_s64_t MAX_U32 = ((1ull << 32u) - 1u);
00634 static const llrp_s64_t MIN_U32 = 0ull;
00635 static const llrp_s64_t MAX_S32 = ((1ull << 31u) - 1u);
00636 static const llrp_s64_t MIN_S32 = (-1ll - MAX_S32);
00637
00638 static const llrp_s64_t MAX_U64 = ((1ull << 63u) - 1u);
00639 static const llrp_s64_t MIN_U64 = 0ull;
00640 static const llrp_s64_t MAX_S64 = ((1ull << 63u) - 1u);
00641 static const llrp_s64_t MIN_S64 = (-1ll - MAX_S64);
00642
00643 };
00644
00645 };