VirtualBox

Changeset 74386 in vbox


Ignore:
Timestamp:
Sep 20, 2018 3:46:38 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
125207
Message:

IPRT/rest: Early support for polymorphic data objects in the data model. bugref:9167 ..\..\ e:\vbox\svn\trunk\include\iprt\

Location:
trunk/src/VBox/Runtime/common/rest
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/rest/RTCRestAnyObject.cpp

    r74347 r74386  
    382382
    383383
     384RTCRestObjectBase *RTCRestAnyObject::baseClone() const
     385{
     386    RTCRestAnyObject *pClone = new (std::nothrow) RTCRestAnyObject();
     387    if (pClone)
     388    {
     389        int rc = pClone->assignCopy(*this);
     390        if (RT_SUCCESS(rc))
     391            return pClone;
     392        delete pClone;
     393    }
     394    return NULL;
     395}
     396
     397
    384398int RTCRestAnyObject::setNull(void)
    385399{
  • trunk/src/VBox/Runtime/common/rest/RTCRestArrayBase.cpp

    r74263 r74386  
    9090*********************************************************************************************************************************/
    9191
     92RTCRestObjectBase *RTCRestArrayBase::baseClone() const
     93{
     94    RTCRestArrayBase *pClone = createClone();
     95    if (pClone)
     96    {
     97        int rc = pClone->copyArrayWorker(*this, false /*fThrow*/);
     98        if (RT_SUCCESS(rc))
     99            return pClone;
     100        delete pClone;
     101    }
     102    return NULL;
     103}
     104
     105
    92106int RTCRestArrayBase::resetToDefault()
    93107{
     
    458472{
    459473    int rc;
    460     RTCRestObjectBase *pValueCopy = createValueCopy(&a_rValue);
     474    RTCRestObjectBase *pValueCopy = a_rValue.baseClone();
    461475    if (pValueCopy)
    462476    {
  • trunk/src/VBox/Runtime/common/rest/RTCRestStringMapBase.cpp

    r74197 r74386  
    7373*   Overridden base object methods                                                                                               *
    7474*********************************************************************************************************************************/
     75
     76RTCRestObjectBase *RTCRestStringMapBase::baseClone() const
     77{
     78    RTCRestStringMapBase *pClone = createClone();
     79    if (pClone)
     80    {
     81        int rc = pClone->copyMapWorker(*this, false /*fThrow*/);
     82        if (RT_SUCCESS(rc))
     83            return pClone;
     84        delete pClone;
     85    }
     86    return NULL;
     87}
     88
    7589
    7690int RTCRestStringMapBase::resetToDefault()
     
    394408{
    395409    int rc;
    396     RTCRestObjectBase *pValueCopy = createValueCopy(&a_rValue);
     410    RTCRestObjectBase *pValueCopy = a_rValue.baseClone();
    397411    if (pValueCopy)
    398412    {
  • trunk/src/VBox/Runtime/common/rest/rest-binary.cpp

    r74228 r74386  
    176176
    177177/* Overridden methods: */
     178
     179RTCRestObjectBase *RTCRestBinary::baseClone() const
     180{
     181    RTCRestBinary *pClone = new (std::nothrow) RTCRestBinary();
     182    if (pClone)
     183    {
     184        int rc = pClone->assignCopy(*this);
     185        if (RT_SUCCESS(rc))
     186            return pClone;
     187        delete pClone;
     188    }
     189    return NULL;
     190}
     191
     192
    178193int RTCRestBinary::setNull(void)
    179194{
     
    302317    AssertMsgFailed(("Please use assignReadOnly!\n"));
    303318    return assignReadOnly(a_pvBuf, a_cbBuf);
     319}
     320
     321
     322RTCRestObjectBase *RTCRestBinaryParameter::baseClone() const
     323{
     324    RTCRestBinaryParameter *pClone = new (std::nothrow) RTCRestBinaryParameter();
     325    if (pClone)
     326    {
     327        int rc = pClone->assignCopy(*this);
     328        if (RT_SUCCESS(rc))
     329            return pClone;
     330        delete pClone;
     331    }
     332    return NULL;
    304333}
    305334
     
    487516    AssertStmt(a_cbBuf <= m_cbMaxDownload, m_cbMaxDownload = a_cbBuf);
    488517    return RTCRestBinary::assignWriteable(a_pvBuf, a_cbBuf);
     518}
     519
     520
     521RTCRestObjectBase *RTCRestBinaryResponse::baseClone() const
     522{
     523    RTCRestBinaryResponse *pClone = new (std::nothrow) RTCRestBinaryResponse();
     524    if (pClone)
     525    {
     526        int rc = pClone->assignCopy(*this);
     527        if (RT_SUCCESS(rc))
     528            return pClone;
     529        delete pClone;
     530    }
     531    return NULL;
    489532}
    490533
  • trunk/src/VBox/Runtime/common/rest/rest-primary-object-types.cpp

    r74356 r74386  
    185185
    186186
     187RTCRestObjectBase *RTCRestBool::baseClone() const
     188{
     189    return new (std::nothrow) RTCRestBool(*this);
     190}
     191
     192
    187193int RTCRestBool::resetToDefault()
    188194{
     
    356362
    357363
     364RTCRestObjectBase *RTCRestInt64::baseClone() const
     365{
     366    return new (std::nothrow) RTCRestInt64(*this);
     367}
     368
     369
    358370int RTCRestInt64::resetToDefault()
    359371{
     
    510522    m_iValue = a_rThat.m_iValue;
    511523    return VINF_SUCCESS;
     524}
     525
     526
     527RTCRestObjectBase *RTCRestInt32::baseClone() const
     528{
     529    return new (std::nothrow) RTCRestInt32(*this);
    512530}
    513531
     
    690708
    691709
     710RTCRestObjectBase *RTCRestInt16::baseClone() const
     711{
     712    return new (std::nothrow) RTCRestInt16(*this);
     713}
     714
     715
    692716int RTCRestInt16::resetToDefault()
    693717{
     
    856880    m_rdValue = a_rdValue;
    857881    m_fNullIndicator = false;
     882}
     883
     884
     885RTCRestObjectBase *RTCRestDouble::baseClone() const
     886{
     887    return new (std::nothrow) RTCRestDouble(*this);
    858888}
    859889
     
    10301060/** Default constructor. */
    10311061RTCRestString::RTCRestString()
    1032     : RTCString()
    1033     , RTCRestObjectBase()
     1062    : RTCRestObjectBase()
     1063    , RTCString()
    10341064{
    10351065}
     
    10381068/** Copy constructor. */
    10391069RTCRestString::RTCRestString(RTCRestString const &a_rThat)
    1040     : RTCString(a_rThat)
    1041     , RTCRestObjectBase(a_rThat)
     1070    : RTCRestObjectBase(a_rThat)
     1071    , RTCString(a_rThat)
    10421072{
    10431073}
     
    10531083/** From value constructor. */
    10541084RTCRestString::RTCRestString(const char *a_pszSrc)
    1055     : RTCString(a_pszSrc)
    1056     , RTCRestObjectBase()
     1085    : RTCRestObjectBase()
     1086    , RTCString(a_pszSrc)
    10571087{
    10581088}
     
    10931123    m_fNullIndicator = true;
    10941124    return VINF_SUCCESS;
     1125}
     1126
     1127
     1128RTCRestObjectBase *RTCRestString::baseClone() const
     1129{
     1130    RTCRestString *pClone = new (std::nothrow) RTCRestString();
     1131    if (pClone)
     1132    {
     1133        int rc = pClone->assignCopy(*this);
     1134        if (RT_SUCCESS(rc))
     1135            return pClone;
     1136        delete pClone;
     1137    }
     1138    return NULL;
    10951139}
    10961140
     
    13661410    m_enmFormat      = a_rThat.m_enmFormat;
    13671411    return m_strFormatted.assignNoThrow(a_rThat.m_strFormatted);
     1412}
     1413
     1414
     1415RTCRestObjectBase *RTCRestDate::baseClone() const
     1416{
     1417    RTCRestDate *pClone = new (std::nothrow) RTCRestDate();
     1418    if (pClone)
     1419    {
     1420        int rc = pClone->assignCopy(*this);
     1421        if (RT_SUCCESS(rc))
     1422            return pClone;
     1423        delete pClone;
     1424    }
     1425    return NULL;
    13681426}
    13691427
     
    20102068
    20112069
     2070RTCRestObjectBase  *RTCRestStringEnumBase::cloneWorker(RTCRestStringEnumBase *a_pDst) const
     2071{
     2072    if (a_pDst)
     2073    {
     2074        int rc = a_pDst->assignCopy(*this);
     2075        if (RT_SUCCESS(rc))
     2076            return a_pDst;
     2077        delete a_pDst;
     2078    }
     2079    return NULL;
     2080}
     2081
     2082
    20122083
    20132084/*********************************************************************************************************************************
     
    21702241}
    21712242
     2243
     2244
     2245/*********************************************************************************************************************************
     2246*   RTCRestPolyDataObject                                                                                                        *
     2247*********************************************************************************************************************************/
     2248
     2249RTCRestPolyDataObject::RTCRestPolyDataObject()
     2250    : RTCRestDataObject()
     2251{
     2252}
     2253
     2254
     2255RTCRestPolyDataObject::RTCRestPolyDataObject(RTCRestPolyDataObject const &a_rThat)
     2256    : RTCRestDataObject(a_rThat)
     2257{
     2258}
     2259
     2260
     2261RTCRestPolyDataObject::~RTCRestPolyDataObject()
     2262{
     2263}
     2264
     2265
     2266int RTCRestPolyDataObject::resetToDefault()
     2267{
     2268    return RTCRestDataObject::resetToDefault();
     2269}
     2270
     2271
     2272bool RTCRestPolyDataObject::isChild() const
     2273{
     2274    return false;
     2275}
     2276
     2277
     2278RTCRestPolyDataObject &RTCRestPolyDataObject::operator=(RTCRestPolyDataObject const &a_rThat)
     2279{
     2280    RTCRestDataObject::operator=(a_rThat);
     2281    return *this;
     2282}
     2283
Note: See TracChangeset for help on using the changeset viewer.

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