Changeset 73900 in vbox
- Timestamp:
- Aug 26, 2018 8:28:30 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 124617
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/cpp/restbase.h
r73895 r73900 273 273 * @param a_rDst The destination for the serialization. 274 274 */ 275 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) = 0;275 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const = 0; 276 276 277 277 /** … … 284 284 285 285 /** 286 * Flags for toString(). 287 * 288 * The kCollectionFormat_xxx bunch controls multiple values in arrays 289 * are formatted. They are ignored by everyone else. 290 */ 291 enum 292 { 293 kCollectionFormat_cvs = 0, /**< Comma-separated list. */ 294 kCollectionFormat_ssv, /**< Space-separated list. */ 295 kCollectionFormat_tsv, /**< Tab-separated list. */ 296 kCollectionFormat_pipes /**< Pipe-separated list. */ 297 }; 298 299 /** 286 300 * String conversion. 287 301 * … … 290 304 * @returns IPRT status code. 291 305 * @param a_pDst Pointer to the destionation string. 292 * @param a_fFlags For future tricks, MBZ.293 */ 294 virtual int toString(RTCString *a_pDst, uint32_t fFlags = 0);306 * @param a_fFlags kCollectionFormat_xxx. 307 */ 308 virtual int toString(RTCString *a_pDst, uint32_t a_fFlags = kCollectionFormat_cvs) const; 295 309 296 310 /** … … 299 313 * @returns String represenation. 300 314 */ 301 RTCString toString() ;315 RTCString toString() const; 302 316 303 317 /** … … 327 341 /* Overridden methods: */ 328 342 virtual void resetToDefault() RT_OVERRIDE; 329 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) RT_OVERRIDE;343 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 330 344 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE; 331 virtual int toString(RTCString *a_pDst, uint32_t fFlags = 0)RT_OVERRIDE;345 virtual int toString(RTCString *a_pDst, uint32_t a_fFlags = 0) const RT_OVERRIDE; 332 346 virtual const char *getType(void) RT_OVERRIDE; 333 347 … … 357 371 /* Overridden methods: */ 358 372 virtual void resetToDefault() RT_OVERRIDE; 359 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) RT_OVERRIDE;373 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 360 374 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE; 361 virtual int toString(RTCString *a_pDst, uint32_t fFlags = 0)RT_OVERRIDE;375 virtual int toString(RTCString *a_pDst, uint32_t a_fFlags = 0) const RT_OVERRIDE; 362 376 virtual const char *getType(void) RT_OVERRIDE; 363 377 … … 387 401 /* Overridden methods: */ 388 402 virtual void resetToDefault() RT_OVERRIDE; 389 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) RT_OVERRIDE;403 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 390 404 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE; 391 virtual int toString(RTCString *a_pDst, uint32_t fFlags = 0)RT_OVERRIDE;405 virtual int toString(RTCString *a_pDst, uint32_t a_fFlags = 0) const RT_OVERRIDE; 392 406 virtual const char *getType(void) RT_OVERRIDE; 393 407 … … 417 431 /* Overridden methods: */ 418 432 virtual void resetToDefault() RT_OVERRIDE; 419 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) RT_OVERRIDE;433 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 420 434 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE; 421 virtual int toString(RTCString *a_pDst, uint32_t fFlags = 0)RT_OVERRIDE;435 virtual int toString(RTCString *a_pDst, uint32_t a_fFlags = 0) const RT_OVERRIDE; 422 436 virtual const char *getType(void) RT_OVERRIDE; 423 437 … … 447 461 /* Overridden methods: */ 448 462 virtual void resetToDefault() RT_OVERRIDE; 449 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) RT_OVERRIDE;463 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 450 464 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE; 451 virtual int toString(RTCString *a_pDst, uint32_t fFlags = 0)RT_OVERRIDE;465 virtual int toString(RTCString *a_pDst, uint32_t a_fFlags = 0) const RT_OVERRIDE; 452 466 virtual const char *getType(void) RT_OVERRIDE; 453 467 … … 477 491 /* Overridden methods: */ 478 492 virtual void resetToDefault() RT_OVERRIDE; 479 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) RT_OVERRIDE;493 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 480 494 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE; 481 virtual int toString(RTCString *a_pDst, uint32_t fFlags = 0)RT_OVERRIDE;495 virtual int toString(RTCString *a_pDst, uint32_t a_fFlags = 0) const RT_OVERRIDE; 482 496 virtual const char *getType(void) RT_OVERRIDE; 483 497 }; … … 495 509 496 510 virtual void resetToDefault() RT_OVERRIDE; 497 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) RT_OVERRIDE;511 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 498 512 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE 499 513 { … … 516 530 517 531 virtual void resetToDefault() RT_OVERRIDE; 518 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) RT_OVERRIDE;532 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 519 533 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE 520 534 { … … 544 558 * 545 559 * @returns IPRT status code. 546 * @param a_hHttp The HTTP handle to prepare for transmitting. 547 */ 548 virtual int xmitPrepare(RTHTTP a_hHttp) const = 0; 560 * @param a_pstrPath Where to set path parameters. Will be appended to the base path. 561 * @param a_pstrQuery Where to set query parameters. 562 * @param a_hHttp Where to set header parameters and such. 563 * @param a_pstrBody Where to set body parameters. 564 */ 565 virtual int xmitPrepare(RTCString *a_pStrPath, RTCString *a_pStrQuery, RTHTTP a_hHttp, RTCString *a_pStrBody) const = 0; 549 566 550 567 /** … … 592 609 * @returns IPRT status code. 593 610 * @param a_hHttp The HTTP handle to prepare for receiving. 594 */ 595 virtual int receivePrepare(RTHTTP a_hHttp) 596 { 597 RT_NOREF(a_hHttp); 611 * @param a_pppvHdr If a header callback handler is installed, set the value pointed to to NULL. 612 * @param a_pppvBody If a body callback handler is installed, set the value pointed to to NULL. 613 */ 614 virtual int receivePrepare(RTHTTP a_hHttp, void ***a_pppvHdr, void ***a_pppvBody) 615 { 616 RT_NOREF(a_hHttp, a_pppvHdr, a_pppvBody); 598 617 return VINF_SUCCESS; 599 618 } 600 619 601 620 /** 602 * Callback that consumes HTTP header data from the server.603 *604 * @returns IPRT status code?605 * @param a_pvData Body data.606 * @param a_cbData Amount of body data.607 *608 * @todo good idea?609 */610 virtual int consumeHeader(const char *a_pvData, size_t a_cbData)611 {612 RT_NOREF(a_pvData, a_cbData);613 return VINF_SUCCESS;614 }615 616 /**617 * Callback that consumes HTTP body data from the server.618 *619 * @returns IPRT status code?620 * @param a_pvData Body data.621 * @param a_cbData Amount of body data.622 *623 * @todo good idea?624 */625 virtual int consumeBody(const char *a_pvData, size_t a_cbData)626 {627 RT_NOREF(a_pvData, a_cbData);628 return VINF_SUCCESS;629 }630 631 /**632 621 * Called when the HTTP request has been completely received. 633 622 * 634 * @returns IPRT status code?635 623 * @param a_rcStatus Negative numbers are IPRT errors, positive are HTTP status codes. 636 624 * @param a_hHttp The HTTP handle the request was performed on. 637 625 * This can be NIL_RTHTTP should something fail early, in 638 626 * which case it is possible receivePrepare() wasn't called. 639 */ 640 virtual int receiveComplete(int a_rcStatus, RTHTTP a_hHttp) 627 * 628 * @note Called before consumeHeaders() and consumeBody(). 629 */ 630 virtual void receiveComplete(int a_rcStatus, RTHTTP a_hHttp) 641 631 { 642 632 RT_NOREF_PV(a_hHttp); 643 633 m_rcStatus = a_rcStatus; 644 return a_rcStatus; 634 } 635 636 /** 637 * Callback that consumes HTTP header data from the server. 638 * 639 * @param a_pvData Body data. 640 * @param a_cbData Amount of body data. 641 * 642 * @note Called after receiveComplete().. 643 */ 644 virtual void consumeHeaders(const char *a_pvData, size_t a_cbData) 645 { 646 RT_NOREF(a_pvData, a_cbData); 647 } 648 649 /** 650 * Callback that consumes HTTP body data from the server. 651 * 652 * @param a_pvData Body data. 653 * @param a_cbData Amount of body data. 654 * 655 * @note Called after consumeHeaders(). 656 */ 657 virtual void consumeBody(const char *a_pvData, size_t a_cbData) 658 { 659 RT_NOREF(a_pvData, a_cbData); 660 } 661 662 /** 663 * Called after status, headers and body all have been presented. 664 * 665 * @returns IPRT status code. 666 */ 667 virtual void receiveFinal() 668 { 645 669 } 646 670 -
trunk/src/VBox/Runtime/common/rest/rest-primary-object-types.cpp
r73898 r73900 56 56 57 57 58 int RTCRestObjectBase::toString(RTCString *a_pDst, uint32_t fFlags)59 { 60 Assert( fFlags == 0);61 RT_NOREF(fFlags); 58 int RTCRestObjectBase::toString(RTCString *a_pDst, uint32_t a_fFlags /*= 0*/) const 59 { 60 Assert(a_fFlags == 0); RT_NOREF(a_fFlags); 61 62 62 /* 63 63 * Just wrap the JSON serialization method. … … 69 69 70 70 71 RTCString RTCRestObjectBase::toString() 71 RTCString RTCRestObjectBase::toString() const 72 72 { 73 73 RTCString strRet; … … 124 124 125 125 126 RTCRestOutputBase &RTCRestBool::serializeAsJson(RTCRestOutputBase &a_rDst) 126 RTCRestOutputBase &RTCRestBool::serializeAsJson(RTCRestOutputBase &a_rDst) const 127 127 { 128 128 a_rDst.printf(m_fValue ? "true" : "false"); … … 156 156 157 157 158 int RTCRestBool::toString(RTCString *a_pDst, uint32_t fFlags /*= 0*/)159 { 160 Assert( !fFlags);161 RT_NOREF(fFlags); 158 int RTCRestBool::toString(RTCString *a_pDst, uint32_t a_fFlags /*= 0*/) const 159 { 160 Assert(a_fFlags == 0); RT_NOREF(a_fFlags); 161 162 162 /* Be a little careful here to avoid throwing anything. */ 163 163 int rc = a_pDst->reserveNoThrow(m_fValue ? sizeof("true") : sizeof("false")); … … 225 225 226 226 227 RTCRestOutputBase &RTCRestInt64::serializeAsJson(RTCRestOutputBase &a_rDst) 227 RTCRestOutputBase &RTCRestInt64::serializeAsJson(RTCRestOutputBase &a_rDst) const 228 228 { 229 229 a_rDst.printf("%RI64", m_iValue); … … 254 254 255 255 256 int RTCRestInt64::toString(RTCString *a_pDst, uint32_t fFlags /*= 0*/)257 { 258 Assert( !fFlags);259 RT_NOREF(fFlags); 256 int RTCRestInt64::toString(RTCString *a_pDst, uint32_t a_fFlags /*= 0*/) const 257 { 258 Assert(a_fFlags == 0); RT_NOREF(a_fFlags); 259 260 260 /* Be a little careful here to avoid throwing anything. */ 261 261 char szValue[64]; … … 321 321 322 322 323 RTCRestOutputBase &RTCRestInt32::serializeAsJson(RTCRestOutputBase &a_rDst) 323 RTCRestOutputBase &RTCRestInt32::serializeAsJson(RTCRestOutputBase &a_rDst) const 324 324 { 325 325 a_rDst.printf("%RI32", m_iValue); … … 356 356 357 357 358 int RTCRestInt32::toString(RTCString *a_pDst, uint32_t fFlags /*= 0*/)359 { 360 Assert( !fFlags);361 RT_NOREF(fFlags); 358 int RTCRestInt32::toString(RTCString *a_pDst, uint32_t a_fFlags /*= 0*/) const 359 { 360 Assert(a_fFlags == 0); RT_NOREF(a_fFlags); 361 362 362 /* Be a little careful here to avoid throwing anything. */ 363 363 char szValue[16]; … … 423 423 424 424 425 RTCRestOutputBase &RTCRestInt16::serializeAsJson(RTCRestOutputBase &a_rDst) 425 RTCRestOutputBase &RTCRestInt16::serializeAsJson(RTCRestOutputBase &a_rDst) const 426 426 { 427 427 a_rDst.printf("%RI16", m_iValue); … … 458 458 459 459 460 int RTCRestInt16::toString(RTCString *a_pDst, uint32_t fFlags /*= 0*/)461 { 462 Assert( !fFlags);463 RT_NOREF(fFlags); 460 int RTCRestInt16::toString(RTCString *a_pDst, uint32_t a_fFlags /*= 0*/) const 461 { 462 Assert(a_fFlags == 0); RT_NOREF(a_fFlags); 463 464 464 /* Be a little careful here to avoid throwing anything. */ 465 465 char szValue[8]; … … 517 517 518 518 519 RTCRestOutputBase &RTCRestDouble::serializeAsJson(RTCRestOutputBase &a_rDst) 519 RTCRestOutputBase &RTCRestDouble::serializeAsJson(RTCRestOutputBase &a_rDst) const 520 520 { 521 521 /* Just a simple approximation here. */ … … 540 540 541 541 542 int RTCRestDouble::toString(RTCString *a_pDst, uint32_t fFlags /*= 0*/)543 { 544 Assert( !fFlags);545 RT_NOREF(fFlags); 542 int RTCRestDouble::toString(RTCString *a_pDst, uint32_t a_fFlags /*= 0*/) const 543 { 544 Assert(a_fFlags == 0); RT_NOREF(a_fFlags); 545 546 546 /* Just a simple approximation here. */ 547 547 /** @todo implement floating point values for json. */ … … 613 613 614 614 615 RTCRestOutputBase &RTCRestString::serializeAsJson(RTCRestOutputBase &a_rDst) 615 RTCRestOutputBase &RTCRestString::serializeAsJson(RTCRestOutputBase &a_rDst) const 616 616 { 617 617 a_rDst.printf("%RJs", m_psz); … … 647 647 648 648 649 int RTCRestString::toString(RTCString *a_pDst, uint32_t fFlags /*= 0*/)650 { 651 Assert( !fFlags);652 RT_NOREF(fFlags); 649 int RTCRestString::toString(RTCString *a_pDst, uint32_t a_fFlags /*= 0*/) const 650 { 651 Assert(a_fFlags == 0); RT_NOREF(a_fFlags); 652 653 653 /* Careful as always. */ 654 654 if (m_cch)
Note:
See TracChangeset
for help on using the changeset viewer.