VirtualBox

Changeset 74347 in vbox for trunk/include/iprt/cpp


Ignore:
Timestamp:
Sep 18, 2018 4:10:34 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
125160
Message:

IPRT/rest: Implemented inheritance in the data model. Introducing a new base class RTCRestDataObject for data model classes. bugref:9167

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/cpp/restbase.h

    r74263 r74347  
    252252
    253253/**
    254  * Abstract base class for REST data objects.
     254 * Abstract base class for REST primitive types and data objects (via
     255 * RTCRestDataObject).
    255256 *
    256257 * The only information this keeps is the null indicator.
     
    371372        kTypeClass_Uuid,                /**< UUID. */
    372373        kTypeClass_Binary,              /**< Binary blob. */
    373         kTypeClass_Object,              /**< Object (any kind of data model object). */
     374        kTypeClass_DataObject,          /**< Data object child (RTCRestDataObject). */
     375        kTypeClass_AnyObject,           /**< Any kind of object (RTCRestAnyObject). */
    374376        kTypeClass_Array,               /**< Array (containing any kind of object). */
    375377        kTypeClass_StringMap,           /**< String map (containing any kind of object). */
     
    380382     * Returns the object type class.
    381383     */
    382     virtual kTypeClass typeClass(void) const;
     384    virtual kTypeClass typeClass(void) const = 0;
    383385
    384386    /**
     
    980982
    981983
     984/**
     985 * Abstract base class for REST data model objects.
     986 */
     987class RT_DECL_CLASS RTCRestDataObject : public RTCRestObjectBase
     988{
     989public:
     990    RTCRestDataObject();
     991    RTCRestDataObject(RTCRestDataObject const &a_rThat);
     992    virtual ~RTCRestDataObject();
     993
     994    /* Overridden methods:*/
     995    virtual int resetToDefault() RT_OVERRIDE;
     996    virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE;
     997    virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE;
     998    virtual kTypeClass typeClass(void) const RT_OVERRIDE;
     999
     1000    /** Safe copy assignment method. */
     1001    virtual int assignCopy(RTCRestDataObject const &a_rThat);
     1002
     1003    /**
     1004     * Serialize the members as JSON.
     1005     *
     1006     * @returns Leading separator prefix (empty string or comma string).
     1007     * @param   a_rDst      The destination for the serialization.
     1008     * @param   a_pszSep    Leading separator prefix (empty or comma).
     1009     */
     1010    virtual const char *serializeMembersAsJson(RTCRestOutputBase &a_rDst, const char *a_pszSep) const;
     1011
     1012    /**
     1013     * Deserialize object from the given JSON iterator.
     1014     *
     1015     * @returns IPRT status code.
     1016     * @retval  VERR_NOT_FOUND if field is unknown.  Top level caller will do
     1017     *          invoke unknownField() on it.
     1018     *
     1019     * @param   a_rCursor   The JSON cursor with the current member.
     1020     * @param   a_cchName   The length of a_rCursor.m_pszName.
     1021     */
     1022    virtual int deserializeMemberFromJson(RTCRestJsonCursor const &a_rCursor, size_t a_cchName);
     1023
     1024protected:
     1025    /** The is-set bits for all the fields. */
     1026    uint64_t m_fIsSet;
     1027
     1028    /** Copy assignment operator. */
     1029    RTCRestDataObject &operator=(RTCRestDataObject const &a_rThat);
     1030};
     1031
     1032
    9821033/** @} */
    9831034
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette