VirtualBox

Ignore:
Timestamp:
Sep 20, 2018 10:39:39 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
125220
Message:

IPRT/rest: Prepped for polymorphic body responses. bugref:9167

File:
1 edited

Legend:

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

    r74251 r74396  
    336336
    337337
    338 void RTCRestClientResponseBase::deserializeBody(RTCRestObjectBase *a_pDst, const char *a_pchData, size_t a_cbData)
     338void RTCRestClientResponseBase::deserializeBody(const char *a_pchData, size_t a_cbData, const char *a_pszBodyName)
    339339{
    340340    if (m_strContentType.startsWith("application/json"))
     
    348348            if (RT_SUCCESS(rc))
    349349            {
    350                 PrimaryJsonCursorForBody PrimaryCursor(hValue, a_pDst->typeName(), this); /* note: consumes hValue */
    351                 a_pDst->deserializeFromJson(PrimaryCursor.m_Cursor);
     350                PrimaryJsonCursorForBody PrimaryCursor(hValue, a_pszBodyName, this); /* note: consumes hValue */
     351                deserializeBodyFromJsonCursor(PrimaryCursor.m_Cursor);
    352352            }
    353353            else if (RTErrInfoIsSet(&ErrInfo.Core))
    354354                addError(rc, "Error %Rrc parsing server response as JSON (type %s): %s",
    355                          rc, a_pDst->typeName(), ErrInfo.Core.pszMsg);
     355                         rc, a_pszBodyName, ErrInfo.Core.pszMsg);
    356356            else
    357                 addError(rc, "Error %Rrc parsing server response as JSON (type %s)", rc, a_pDst->typeName());
     357                addError(rc, "Error %Rrc parsing server response as JSON (type %s)", rc, a_pszBodyName);
    358358        }
    359359        else if (rc == VERR_INVALID_UTF8_ENCODING)
    360360            addError(VERR_REST_RESPONSE_INVALID_UTF8_ENCODING, "Invalid UTF-8 body encoding (object type %s; Content-Type: %s)",
    361                      a_pDst->typeName(), m_strContentType.c_str());
     361                     a_pszBodyName, m_strContentType.c_str());
    362362        else if (rc == VERR_BUFFER_UNDERFLOW)
    363363            addError(VERR_REST_RESPONSE_EMBEDDED_ZERO_CHAR, "Embedded zero character in response (object type %s; Content-Type: %s)",
    364                      a_pDst->typeName(), m_strContentType.c_str());
     364                     a_pszBodyName, m_strContentType.c_str());
    365365        else
    366366            addError(rc, "Unexpected body validation error (object type %s; Content-Type: %s): %Rrc",
    367                      a_pDst->typeName(), m_strContentType.c_str(), rc);
     367                     a_pszBodyName, m_strContentType.c_str(), rc);
    368368    }
    369369    else
    370370        addError(VERR_REST_RESPONSE_CONTENT_TYPE_NOT_SUPPORTED, "Unsupported content type for '%s': %s",
    371                  a_pDst->typeName(), m_strContentType.c_str());
    372 }
    373 
     371                 a_pszBodyName, m_strContentType.c_str());
     372}
     373
     374
     375void RTCRestClientResponseBase::deserializeBodyFromJsonCursor(RTCRestJsonCursor const &a_rCursor)
     376{
     377    a_rCursor.m_pPrimary->addError(a_rCursor, VERR_REST_INTERNAL_ERROR_8, "deserializeBodyFromJsonCursor must be overridden!");
     378    AssertFailed();
     379}
     380
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