Changeset 74402 in vbox for trunk/include/iprt/cpp
- Timestamp:
- Sep 21, 2018 9:25:55 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 125227
- Location:
- trunk/include/iprt/cpp
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/cpp/restanyobject.h
r74387 r74402 113 113 /** Factory method. */ 114 114 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void); 115 /** Deserialization w/ instantiation. */ 116 static FNDESERIALIZEINSTANCEFROMJSON deserializeInstanceFromJson; 115 117 116 118 protected: -
trunk/include/iprt/cpp/restarray.h
r74387 r74402 147 147 148 148 /** 149 * For accessing the static deserializeInstanceFromJson() method of the value. 150 */ 151 virtual int deserializeValueInstanceFromJson(RTCRestJsonCursor const &a_rCursor, RTCRestObjectBase **a_ppInstance) = 0; 152 153 /** 149 154 * Worker for the copy constructor and the assignment operator. 150 155 * … … 244 249 } 245 250 251 /** @copydoc RTCRestObjectBase::FNDESERIALIZEINSTANCEFROMJSON */ 252 static DECLCALLBACK(int) deserializeInstanceFromJson(RTCRestJsonCursor const &a_rCursor, RTCRestObjectBase **a_ppInstance) 253 { 254 *a_ppInstance = new (std::nothrow) RTCRestArray<ElementType>(); 255 if (*a_ppInstance) 256 return (*a_ppInstance)->deserializeFromJson(a_rCursor); 257 return a_rCursor.m_pPrimary->addError(a_rCursor, VERR_NO_MEMORY, "Out of memory"); 258 } 259 246 260 247 261 /** … … 418 432 return new (std::nothrow) ElementType(); 419 433 } 434 435 virtual int deserializeValueInstanceFromJson(RTCRestJsonCursor const &a_rCursor, RTCRestObjectBase **a_ppInstance) RT_OVERRIDE 436 { 437 return ElementType::deserializeInstanceFromJson(a_rCursor, a_ppInstance); 438 } 420 439 }; 421 440 -
trunk/include/iprt/cpp/restbase.h
r74390 r74402 312 312 313 313 /** 314 * Polymorphic JSON deserialization helper that instantiate the matching class using 315 * the discriminator field. 316 * 317 * @returns IPRT status code. 318 * @param a_rCursor The JSON cursor. 319 * @param a_ppInstance Where to return the deserialized instance. 320 * May return an object on failure. 321 */ 322 typedef DECLCALLBACK(int) FNDESERIALIZEINSTANCEFROMJSON(RTCRestJsonCursor const &a_rCursor, RTCRestObjectBase **a_ppInstance); 323 /** Pointer to a FNDESERIALIZEINSTANCEFROMJSON function. */ 324 typedef FNDESERIALIZEINSTANCEFROMJSON *PFNDESERIALIZEINSTANCEFROMJSON; 325 326 /** 314 327 * Flags for toString(). 315 328 * … … 444 457 /** Factory method. */ 445 458 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void); 459 /** Deserialization w/ instantiation. */ 460 static FNDESERIALIZEINSTANCEFROMJSON deserializeInstanceFromJson; 446 461 447 462 public: … … 487 502 /** Factory method. */ 488 503 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void); 504 /** Deserialization w/ instantiation. */ 505 static FNDESERIALIZEINSTANCEFROMJSON deserializeInstanceFromJson; 489 506 490 507 public: … … 530 547 /** Factory method. */ 531 548 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void); 549 /** Deserialization w/ instantiation. */ 550 static FNDESERIALIZEINSTANCEFROMJSON deserializeInstanceFromJson; 532 551 533 552 public: … … 573 592 /** Factory method. */ 574 593 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void); 594 /** Deserialization w/ instantiation. */ 595 static FNDESERIALIZEINSTANCEFROMJSON deserializeInstanceFromJson; 575 596 576 597 public: … … 616 637 /** Factory method. */ 617 638 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void); 639 /** Deserialization w/ instantiation. */ 640 static FNDESERIALIZEINSTANCEFROMJSON deserializeInstanceFromJson; 618 641 619 642 public: … … 663 686 /** Factory method. */ 664 687 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void); 688 /** Deserialization w/ instantiation. */ 689 static FNDESERIALIZEINSTANCEFROMJSON deserializeInstanceFromJson; 665 690 666 691 /** @name RTCString assignment methods we need to replace to manage the null indicator … … 729 754 /** Factory method. */ 730 755 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void); 756 /** Deserialization w/ instantiation. */ 757 static FNDESERIALIZEINSTANCEFROMJSON deserializeInstanceFromJson; 731 758 732 759 /** Date formats. */ … … 992 1019 993 1020 /** Factory method. */ 994 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void) { return new (std::nothrow) RTCRestStringEnum(); } 1021 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void) 1022 { 1023 return new (std::nothrow) RTCRestStringEnum(); 1024 } 1025 1026 /** @copydoc RTCRestObjectBase::FNDESERIALIZEINSTANCEFROMJSON */ 1027 static DECLCALLBACK(int) deserializeInstanceFromJson(RTCRestJsonCursor const &a_rCursor, RTCRestObjectBase **a_ppInstance) 1028 { 1029 *a_ppInstance = new (std::nothrow) RTCRestStringEnum(); 1030 if (*a_ppInstance) 1031 return (*a_ppInstance)->deserializeFromJson(a_rCursor); 1032 return a_rCursor.m_pPrimary->addError(a_rCursor, VERR_NO_MEMORY, "Out of memory"); 1033 } 995 1034 996 1035 protected: … … 1056 1095 /** Factory method. */ 1057 1096 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void); 1097 /** Deserialization w/ instantiation. */ 1098 static FNDESERIALIZEINSTANCEFROMJSON deserializeInstanceFromJson; 1058 1099 1059 1100 protected: -
trunk/include/iprt/cpp/reststringmap.h
r74387 r74402 231 231 232 232 /** 233 * For accessing the static deserializeInstanceFromJson() method of the value. 234 */ 235 virtual int deserializeValueInstanceFromJson(RTCRestJsonCursor const &a_rCursor, RTCRestObjectBase **a_ppInstance) = 0; 236 237 /** 233 238 * Worker for the copy constructor and the assignment operator. 234 239 * … … 342 347 } 343 348 349 /** @copydoc RTCRestObjectBase::FNDESERIALIZEINSTANCEFROMJSON */ 350 static DECLCALLBACK(int) deserializeInstanceFromJson(RTCRestJsonCursor const &a_rCursor, RTCRestObjectBase **a_ppInstance) 351 { 352 *a_ppInstance = new (std::nothrow) RTCRestStringMap<ValueType>(); 353 if (*a_ppInstance) 354 return (*a_ppInstance)->deserializeFromJson(a_rCursor); 355 return a_rCursor.m_pPrimary->addError(a_rCursor, VERR_NO_MEMORY, "Out of memory"); 356 } 357 344 358 /** 345 359 * Inserts the given object into the map. … … 454 468 return new (std::nothrow) ValueType(); 455 469 } 470 471 virtual int deserializeValueInstanceFromJson(RTCRestJsonCursor const &a_rCursor, RTCRestObjectBase **a_ppInstance) RT_OVERRIDE 472 { 473 return ValueType::deserializeInstanceFromJson(a_rCursor, a_ppInstance); 474 } 456 475 }; 457 476
Note:
See TracChangeset
for help on using the changeset viewer.