Changeset 73956 in vbox for trunk/src/VBox/Runtime/common/rest
- Timestamp:
- Aug 29, 2018 3:09:34 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 124685
- Location:
- trunk/src/VBox/Runtime/common/rest
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/rest/RTCRestOutputToString.cpp
r73879 r73956 35 35 36 36 37 RTCRestOutputToString::RTCRestOutputToString(RTCString *a_pDst )37 RTCRestOutputToString::RTCRestOutputToString(RTCString *a_pDst, bool a_fAppend /*= false*/) 38 38 : m_pDst(a_pDst) 39 39 , m_fOutOfMemory(false) 40 40 { 41 if (!a_fAppend) 42 m_pDst->setNull(); 41 43 } 42 44 -
trunk/src/VBox/Runtime/common/rest/RTCRestStringMapBase.cpp
r73951 r73956 115 115 */ 116 116 RTJSONIT hIterator; 117 int rcRet = RTJsonIteratorBegin (a_rCursor.m_hValue, &hIterator);117 int rcRet = RTJsonIteratorBeginObject(a_rCursor.m_hValue, &hIterator); 118 118 if (RT_SUCCESS(rcRet)) 119 119 { … … 176 176 rcRet = a_rCursor.m_pPrimary->addError(a_rCursor, rcRet, "RTJsonIteratorBegin failed: %Rrc", rcRet); 177 177 return rcRet; 178 179 178 } 180 179 181 180 // later? 182 // virtual int RTCRestStringMapBase::toString(RTCString *a_pDst, uint32_t a_fFlags = 0) const ;181 // virtual int RTCRestStringMapBase::toString(RTCString *a_pDst, uint32_t a_fFlags = kCollectionFormat_Unspecified) const ; 183 182 // virtual int RTCRestStringMapBase::fromString(RTCString const &a_rValue, const char *a_pszName, PRTERRINFO a_pErrInfo = NULL, 184 183 // uint32_t a_fFlags = kCollectionFormat_Unspecified) ; -
trunk/src/VBox/Runtime/common/rest/rest-primary-object-types.cpp
r73933 r73956 59 59 int RTCRestObjectBase::toString(RTCString *a_pDst, uint32_t a_fFlags /*= kCollectionFormat_Unspecified*/) const 60 60 { 61 Assert(a_fFlags == kCollectionFormat_Unspecified); RT_NOREF(a_fFlags);62 63 61 /* 64 62 * Just wrap the JSON serialization method. 65 63 */ 66 RTCRestOutputToString Tmp(a_pDst );64 RTCRestOutputToString Tmp(a_pDst, RT_BOOL(a_fFlags & kToString_Append)); 67 65 serializeAsJson(Tmp); 68 66 return Tmp.finalize() ? VINF_SUCCESS : VERR_NO_MEMORY; … … 81 79 uint32_t a_fFlags /*= kCollectionFormat_Unspecified*/) 82 80 { 83 Assert(a_fFlags == kCollectionFormat_Unspecified);RT_NOREF(a_fFlags);81 RT_NOREF(a_fFlags); 84 82 85 83 /* … … 185 183 int RTCRestBool::toString(RTCString *a_pDst, uint32_t a_fFlags /*= kCollectionFormat_Unspecified*/) const 186 184 { 187 Assert(a_fFlags == 0); RT_NOREF(a_fFlags); 188 185 if (!(a_fFlags & kToString_Append)) 186 { 187 if (m_fValue) 188 return a_pDst->assignNoThrow(RT_STR_TUPLE("true")); 189 return a_pDst->assignNoThrow(RT_STR_TUPLE("false")); 190 } 189 191 if (m_fValue) 190 return a_pDst->a ssignNoThrow(RT_STR_TUPLE("true"));191 return a_pDst->a ssignNoThrow(RT_STR_TUPLE("false"));192 return a_pDst->appendNoThrow(RT_STR_TUPLE("true")); 193 return a_pDst->appendNoThrow(RT_STR_TUPLE("false")); 192 194 } 193 195 … … 196 198 uint32_t a_fFlags /*= kCollectionFormat_Unspecified*/) 197 199 { 198 Assert(a_fFlags == 0); RT_NOREF(a_fFlags); 200 RT_NOREF(a_fFlags); 201 199 202 if (a_rValue.startsWithWord("true", RTCString::CaseInsensitive)) 200 203 m_fValue = true; … … 299 302 int RTCRestInt64::toString(RTCString *a_pDst, uint32_t a_fFlags /*= kCollectionFormat_Unspecified*/) const 300 303 { 301 Assert(a_fFlags == 0); RT_NOREF(a_fFlags);302 303 return a_pDst-> printfNoThrow("%RI64", m_iValue);304 if (!(a_fFlags & kToString_Append)) 305 return a_pDst->printfNoThrow("%RI64", m_iValue); 306 return a_pDst->appendPrintfNoThrow("%RI64", m_iValue); 304 307 } 305 308 … … 308 311 uint32_t a_fFlags /*= kCollectionFormat_Unspecified*/) 309 312 { 310 Assert(a_fFlags == 0);RT_NOREF(a_fFlags);313 RT_NOREF(a_fFlags); 311 314 312 315 int rc = RTStrToInt64Full(RTStrStripL(a_rValue.c_str()), 10, &m_iValue); … … 415 418 int RTCRestInt32::toString(RTCString *a_pDst, uint32_t a_fFlags /*= kCollectionFormat_Unspecified*/) const 416 419 { 417 Assert(a_fFlags == 0); RT_NOREF(a_fFlags);418 419 return a_pDst-> printfNoThrow("%RI32", m_iValue);420 if (!(a_fFlags & kToString_Append)) 421 return a_pDst->printfNoThrow("%RI32", m_iValue); 422 return a_pDst->appendPrintfNoThrow("%RI32", m_iValue); 420 423 } 421 424 … … 424 427 uint32_t a_fFlags /*= kCollectionFormat_Unspecified*/) 425 428 { 426 Assert(a_fFlags == 0);RT_NOREF(a_fFlags);429 RT_NOREF(a_fFlags); 427 430 428 431 int rc = RTStrToInt32Full(RTStrStripL(a_rValue.c_str()), 10, &m_iValue); … … 531 534 int RTCRestInt16::toString(RTCString *a_pDst, uint32_t a_fFlags /*= kCollectionFormat_Unspecified*/) const 532 535 { 533 Assert(a_fFlags == 0); RT_NOREF(a_fFlags);534 535 return a_pDst-> printfNoThrow("%RI16", m_iValue);536 if (!(a_fFlags & kToString_Append)) 537 return a_pDst->printfNoThrow("%RI16", m_iValue); 538 return a_pDst->appendPrintfNoThrow("%RI16", m_iValue); 536 539 } 537 540 … … 540 543 uint32_t a_fFlags /*= kCollectionFormat_Unspecified*/) 541 544 { 542 Assert(a_fFlags == 0);RT_NOREF(a_fFlags);545 RT_NOREF(a_fFlags); 543 546 544 547 int rc = RTStrToInt16Full(RTStrStripL(a_rValue.c_str()), 10, &m_iValue); … … 626 629 int RTCRestDouble::toString(RTCString *a_pDst, uint32_t a_fFlags /*= kCollectionFormat_Unspecified*/) const 627 630 { 628 Assert(a_fFlags == 0); RT_NOREF(a_fFlags);629 630 631 /* Just a simple approximation here. */ 631 632 /** @todo implement floating point values for json. */ … … 638 639 size_t const cchValue = strlen(szValue); 639 640 640 return a_pDst->assignNoThrow(szValue, cchValue); 641 if (!(a_fFlags & kToString_Append)) 642 return a_pDst->assignNoThrow(szValue, cchValue); 643 return a_pDst->appendNoThrow(szValue, cchValue); 641 644 } 642 645 … … 645 648 uint32_t a_fFlags /*= kCollectionFormat_Unspecified*/) 646 649 { 647 Assert(a_fFlags == 0);RT_NOREF(a_fFlags);650 RT_NOREF(a_fFlags); 648 651 649 652 const char *pszValue = RTStrStripL(a_rValue.c_str()); … … 751 754 int RTCRestString::toString(RTCString *a_pDst, uint32_t a_fFlags /*= kCollectionFormat_Unspecified*/) const 752 755 { 753 Assert(a_fFlags == 0); RT_NOREF(a_fFlags);754 755 return a_pDst->a ssignNoThrow(*this);756 if (!(a_fFlags & kToString_Append)) 757 return a_pDst->assignNoThrow(*this); 758 return a_pDst->appendNoThrow(*this); 756 759 } 757 760 … … 760 763 uint32_t a_fFlags /*= kCollectionFormat_Unspecified*/) 761 764 { 762 Assert(a_fFlags == 0); RT_NOREF(a_fFlags); 763 RT_NOREF(a_pszName); RT_NOREF(a_pErrInfo); 765 RT_NOREF(a_fFlags); RT_NOREF(a_pszName); RT_NOREF(a_pErrInfo); 764 766 765 767 return assignNoThrow(a_rValue);
Note:
See TracChangeset
for help on using the changeset viewer.