Changeset 74040 in vbox for trunk/include/iprt
- Timestamp:
- Sep 3, 2018 12:25:52 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/cpp/restbase.h
r74025 r74040 369 369 kTypeClass_Object, /**< Object (any kind of data model object). */ 370 370 kTypeClass_Array, /**< Array (containing any kind of object). */ 371 kTypeClass_StringMap /**< String map (containing any kind of object). */ 371 kTypeClass_StringMap, /**< String map (containing any kind of object). */ 372 kTypeClass_StringEnum /**< String enum. */ 372 373 } kTypeClass; 373 374 … … 389 390 /** Pointer to factory method. */ 390 391 typedef FNCREATEINSTANCE *PFNCREATEINSTANCE; 391 392 392 393 393 protected: … … 409 409 { 410 410 public: 411 /** Default destructor. */411 /** Default constructor. */ 412 412 RTCRestBool(); 413 413 /** Copy constructor. */ … … 449 449 { 450 450 public: 451 /** Default destructor. */451 /** Default constructor. */ 452 452 RTCRestInt64(); 453 453 /** Copy constructor. */ … … 489 489 { 490 490 public: 491 /** Default destructor. */491 /** Default constructor. */ 492 492 RTCRestInt32(); 493 493 /** Copy constructor. */ … … 529 529 { 530 530 public: 531 /** Default destructor. */531 /** Default constructor. */ 532 532 RTCRestInt16(); 533 533 /** Copy constructor. */ … … 569 569 { 570 570 public: 571 /** Default destructor. */571 /** Default constructor. */ 572 572 RTCRestDouble(); 573 573 /** Copy constructor. */ … … 609 609 { 610 610 public: 611 /** Default destructor. */611 /** Default constructor. */ 612 612 RTCRestString(); 613 613 /** Destructor. */ … … 644 644 645 645 /** 646 * String enum base class. 647 */ 648 class RT_DECL_CLASS RTCRestStringEnumBase : public RTCRestObjectBase 649 { 650 public: 651 /** Enum map entry. */ 652 typedef struct ENUMMAPENTRY 653 { 654 const char *pszName; 655 uint32_t cchName; 656 int32_t iValue; 657 } ENUMMAPENTRY; 658 659 /** Default constructor. */ 660 RTCRestStringEnumBase(); 661 /** Destructor. */ 662 virtual ~RTCRestStringEnumBase(); 663 664 /** Copy constructor. */ 665 RTCRestStringEnumBase(RTCRestStringEnumBase const &a_rThat); 666 /** Copy assignment operator. */ 667 RTCRestStringEnumBase &operator=(RTCRestStringEnumBase const &a_rThat); 668 669 /** Safe copy assignment method. */ 670 int assignCopy(RTCRestStringEnumBase const &a_rThat); 671 /** Safe copy assignment method. */ 672 int assignCopy(RTCString const &a_rThat) { return setByString(a_rThat); } 673 /** Safe copy assignment method. */ 674 int assignCopy(const char *a_pszThat) { return setByString(a_pszThat); } 675 676 /* Overridden methods: */ 677 virtual int resetToDefault() RT_OVERRIDE; 678 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 679 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE; 680 virtual int toString(RTCString *a_pDst, uint32_t a_fFlags = kCollectionFormat_Unspecified) const RT_OVERRIDE; 681 virtual int fromString(RTCString const &a_rValue, const char *a_pszName, PRTERRINFO a_pErrInfo = NULL, 682 uint32_t a_fFlags = kCollectionFormat_Unspecified) RT_OVERRIDE; 683 virtual kTypeClass typeClass(void) const RT_OVERRIDE; 684 685 /** 686 * Sets the value given a C-string value. 687 * 688 * @retval VINF_SUCCESS on success. 689 * @retval VWRN_NOT_FOUND if not mappable to enum value. 690 * @retval VERR_NO_STR_MEMORY if not mappable and we're out of memory. 691 * @param a_pszValue The string value. 692 * @param a_cchValue The string value length. Optional. 693 */ 694 int setByString(const char *a_pszValue, size_t a_cchValue = RTSTR_MAX); 695 696 /** 697 * Sets the value given a string value. 698 * 699 * @retval VINF_SUCCESS on success. 700 * @retval VWRN_NOT_FOUND if not mappable to enum value. 701 * @retval VERR_NO_STR_MEMORY if not mappable and we're out of memory. 702 * @param a_pszValue The string value. 703 */ 704 int setByString(RTCString const &a_rValue); 705 706 /** 707 * Gets the string value. 708 */ 709 const char *getString() const; 710 711 /** Maps the given string value to an enum. */ 712 int stringToEnum(const char *a_pszValue, size_t a_cchValue = RTSTR_MAX); 713 /** Maps the given string value to an enum. */ 714 int stringToEnum(RTCString const &a_rStrValue); 715 /** Maps the given string value to an enum. */ 716 const char *enumToString(int a_iEnumValue, size_t *a_pcchString); 717 718 719 protected: 720 /** The enum value. */ 721 int m_iEnumValue; 722 /** The string value if not a match. */ 723 RTCString m_strValue; 724 725 /** 726 * Worker for setting the object to the given enum value. 727 * 728 * @retval true on success. 729 * @retval false if a_iEnumValue can't be translated. 730 * @param a_iEnumValue The enum value to set. 731 */ 732 bool setWorker(int a_iEnumValue); 733 734 /** 735 * Gets the mapping table. 736 * 737 * @returns Pointer to the translation table. 738 * @param pcEntries Where to return the translation table size. 739 */ 740 virtual ENUMMAPENTRY const *getMappingTable(size_t *pcEntries) const = 0; 741 }; 742 743 744 /** 646 745 * Dynamic REST object. 647 746 * … … 652 751 { 653 752 public: 654 /** Default destructor. */753 /** Default constructor. */ 655 754 RTCRestObject(); 656 755 /** Destructor. */
Note:
See TracChangeset
for help on using the changeset viewer.