Changeset 73933 in vbox for trunk/include/iprt
- Timestamp:
- Aug 28, 2018 8:57:23 PM (6 years ago)
- Location:
- trunk/include/iprt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/cpp/restbase.h
r73930 r73933 295 295 kCollectionFormat_ssv, /**< Space-separated list. */ 296 296 kCollectionFormat_tsv, /**< Tab-separated list. */ 297 kCollectionFormat_pipes /**< Pipe-separated list. */ 297 kCollectionFormat_pipes, /**< Pipe-separated list. */ 298 kCollectionFormat_Mask = 7 /**< Collection type mask. */ 298 299 }; 299 300 … … 328 329 */ 329 330 virtual int fromString(RTCString const &a_rValue, const char *a_pszName, PRTERRINFO a_pErrInfo = NULL, 330 331 uint32_t a_fFlags = kCollectionFormat_Unspecified); 331 332 332 333 /** … … 334 335 */ 335 336 virtual const char *getType(void) = 0; 337 338 /** 339 * Factory method. 340 * @returns Pointer to new object on success, NULL if out of memory. 341 */ 342 typedef DECLCALLBACK(RTCRestObjectBase *) FNCREATEINSTANCE(void); 343 /** Pointer to factory method. */ 344 typedef FNCREATEINSTANCE *PFNCREATEINSTANCE; 336 345 }; 337 346 … … 363 372 virtual const char *getType(void) RT_OVERRIDE; 364 373 374 /** Factory method. */ 375 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void); 376 365 377 public: 366 378 /** The value. */ … … 395 407 virtual const char *getType(void) RT_OVERRIDE; 396 408 409 /** Factory method. */ 410 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void); 411 397 412 public: 398 413 /** The value. */ … … 427 442 virtual const char *getType(void) RT_OVERRIDE; 428 443 444 /** Factory method. */ 445 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void); 446 429 447 public: 430 448 /** The value. */ … … 459 477 virtual const char *getType(void) RT_OVERRIDE; 460 478 479 /** Factory method. */ 480 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void); 481 461 482 public: 462 483 /** The value. */ … … 491 512 virtual const char *getType(void) RT_OVERRIDE; 492 513 514 /** Factory method. */ 515 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void); 516 493 517 public: 494 518 /** The value. */ … … 522 546 uint32_t a_fFlags = kCollectionFormat_Unspecified) RT_OVERRIDE; 523 547 virtual const char *getType(void) RT_OVERRIDE; 548 549 /** Factory method. */ 550 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void); 524 551 }; 525 552 … … 528 555 * Limited array class. 529 556 */ 530 template<class Type> class RTCRestArray : public RTCRestObjectBase557 template<class ElementType> class RTCRestArray : public RTCRestObjectBase 531 558 { 532 559 public: … … 535 562 /** @todo more later. */ 536 563 537 virtual void resetToDefault() RT_OVERRIDE; 538 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 564 virtual void resetToDefault() RT_OVERRIDE 565 { 566 } 567 568 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE 569 { 570 RT_NOREF(a_rDst); 571 return a_rDst; 572 } 573 539 574 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE 540 575 { … … 542 577 return VERR_NOT_IMPLEMENTED; 543 578 } 579 544 580 virtual int fromString(RTCString const &a_rValue, const char *a_pszName, PRTERRINFO a_pErrInfo = NULL, 545 uint32_t a_fFlags = kCollectionFormat_Unspecified) RT_OVERRIDE; 546 virtual const char *getType(void) RT_OVERRIDE; 581 uint32_t a_fFlags = kCollectionFormat_Unspecified) RT_OVERRIDE 582 { 583 RT_NOREF(a_rValue, a_pszName, a_pErrInfo, a_fFlags); 584 return VERR_NOT_IMPLEMENTED; 585 } 586 587 virtual const char *getType(void) RT_OVERRIDE 588 { 589 return "RTCRestArray<ElementType>"; 590 } 591 592 /** Factory method. */ 593 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void) 594 { 595 return new RTCRestArray<ElementType>(); 596 } 597 598 /** Factory method for elements. */ 599 static DECLCALLBACK(RTCRestObjectBase *) createElementInstance(void) 600 { 601 return new ElementType(); 602 } 547 603 }; 548 604 … … 551 607 * Limited map class. 552 608 */ 553 template<class Type> class RTCRestStringMap : public RTCRestObjectBase609 template<class ElementType> class RTCRestStringMap : public RTCRestObjectBase 554 610 { 555 611 public: … … 558 614 /** @todo more later. */ 559 615 560 virtual void resetToDefault() RT_OVERRIDE; 561 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 616 virtual void resetToDefault() RT_OVERRIDE 617 { 618 } 619 620 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE 621 { 622 RT_NOREF(a_rDst); 623 return a_rDst; 624 } 625 562 626 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE 563 627 { … … 565 629 return VERR_NOT_IMPLEMENTED; 566 630 } 631 567 632 virtual int fromString(RTCString const &a_rValue, const char *a_pszName, PRTERRINFO a_pErrInfo = NULL, 568 uint32_t a_fFlags = kCollectionFormat_Unspecified) RT_OVERRIDE; 569 virtual const char *getType(void) RT_OVERRIDE; 633 uint32_t a_fFlags = kCollectionFormat_Unspecified) RT_OVERRIDE 634 { 635 RT_NOREF(a_rValue, a_pszName, a_pErrInfo, a_fFlags); 636 return VERR_NOT_IMPLEMENTED; 637 } 638 639 virtual const char *getType(void) RT_OVERRIDE 640 { 641 return "RTCRestStringMap<ElementType>"; 642 } 643 644 /** Factory method. */ 645 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void) 646 { 647 return new RTCRestStringMap<ElementType>(); 648 } 649 650 /** Factory method for elements. */ 651 static DECLCALLBACK(RTCRestObjectBase *) createElementInstance(void) 652 { 653 return new ElementType(); 654 } 570 655 }; 571 656 … … 743 828 * @param ... Message arguments. 744 829 */ 745 int addError(int a_rc, const char *a_pszFormat, ...); 830 int addError(int a_rc, const char *a_pszFormat, ...); 831 832 /** Field flags. */ 833 enum 834 { 835 /** Collection map, name is a prefix followed by '*'. */ 836 kHdrField_MapCollection = RT_BIT_32(24), 837 /** Array collection, i.e. the heade field may appear more than once. */ 838 kHdrField_ArrayCollection = RT_BIT_32(25), 839 }; 840 841 /** Header field descriptor. */ 842 typedef struct 843 { 844 /** The header field name. */ 845 const char *pszName; 846 /** The length of the field name.*/ 847 uint32_t cchName; 848 /** Flags, TBD. */ 849 uint32_t fFlags; 850 /** Object factory. */ 851 RTCRestObjectBase::PFNCREATEINSTANCE pfnCreateInstance; 852 } HEADERFIELDDESC; 853 854 /** 855 * Helper that extracts fields from the HTTP headers. 856 * 857 * @param a_paFieldsDesc Pointer to an array of field descriptors. 858 * @param a_pappFieldValues Pointer to a parallel array of value pointer pointers. 859 * @param a_cFields Number of field descriptors.. 860 * @param a_pchData The header blob to search. 861 * @param a_cbData The size of the header blob to search. 862 */ 863 void extracHeaderFieldsFromBlob(HEADERFIELDDESC const *a_paFieldDescs, RTCRestObjectBase ***a_pappFieldValues, 864 size_t a_cFields, const char *a_pchData, size_t a_cbData); 746 865 747 866 /** -
trunk/include/iprt/err.h
r73930 r73933 3214 3214 /** Server response contains embedded zero character(s). */ 3215 3215 #define VERR_REST_RESPONSE_EMBEDDED_ZERO_CHAR (-25702) 3216 /** Server response contains unexpected repetitive header field. */ 3217 #define VERR_REST_RESPONSE_REPEAT_HEADER_FIELD (-25703) 3216 3218 /** @} */ 3217 3219
Note:
See TracChangeset
for help on using the changeset viewer.