Changeset 73977 in vbox for trunk/include/iprt/cpp
- Timestamp:
- Aug 30, 2018 12:13:02 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 124713
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/cpp/restbase.h
r73968 r73977 267 267 /** 268 268 * Resets the object to all default values. 269 */ 270 virtual void resetToDefault() = 0; 269 * @returns IPRT status code. 270 */ 271 virtual int resetToDefault() = 0; 271 272 272 273 /** … … 370 371 /** Copy assignment operator. */ 371 372 RTCRestBool &operator=(RTCRestBool const &a_rThat); 373 /** Safe copy assignment method. */ 374 int assignCopy(RTCRestBool const &a_rThat); 372 375 373 376 /* Overridden methods: */ 374 virtual voidresetToDefault() RT_OVERRIDE;377 virtual int resetToDefault() RT_OVERRIDE; 375 378 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 376 379 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE; … … 405 408 /** Copy assignment operator. */ 406 409 RTCRestInt64 &operator=(RTCRestInt64 const &a_rThat); 410 /** Safe copy assignment method. */ 411 int assignCopy(RTCRestInt64 const &a_rThat); 407 412 408 413 /* Overridden methods: */ 409 virtual voidresetToDefault() RT_OVERRIDE;414 virtual int resetToDefault() RT_OVERRIDE; 410 415 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 411 416 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE; … … 440 445 /** Copy assignment operator. */ 441 446 RTCRestInt32 &operator=(RTCRestInt32 const &a_rThat); 447 /** Safe copy assignment method. */ 448 int assignCopy(RTCRestInt32 const &a_rThat); 442 449 443 450 /* Overridden methods: */ 444 virtual voidresetToDefault() RT_OVERRIDE;451 virtual int resetToDefault() RT_OVERRIDE; 445 452 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 446 453 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE; … … 475 482 /** Copy assignment operator. */ 476 483 RTCRestInt16 &operator=(RTCRestInt16 const &a_rThat); 484 /** Safe copy assignment method. */ 485 int assignCopy(RTCRestInt16 const &a_rThat); 477 486 478 487 /* Overridden methods: */ 479 virtual voidresetToDefault() RT_OVERRIDE;488 virtual int resetToDefault() RT_OVERRIDE; 480 489 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 481 490 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE; … … 510 519 /** Copy assignment operator. */ 511 520 RTCRestDouble &operator=(RTCRestDouble const &a_rThat); 521 /** Safe copy assignment method. */ 522 int assignCopy(RTCRestDouble const &a_rThat); 512 523 513 524 /* Overridden methods: */ 514 virtual voidresetToDefault() RT_OVERRIDE;525 virtual int resetToDefault() RT_OVERRIDE; 515 526 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 516 527 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE; … … 537 548 /** Default destructor. */ 538 549 RTCRestString(); 550 /** Destructor. */ 551 virtual ~RTCRestString(); 552 539 553 /** Copy constructor. */ 540 554 RTCRestString(RTCRestString const &a_rThat); … … 543 557 /** From value constructor. */ 544 558 RTCRestString(const char *a_pszSrc); 545 /** Destructor. */ 546 virtual ~RTCRestString(); 559 /** Safe copy assignment method. */ 560 int assignCopy(RTCString const &a_rThat); 561 /** Safe copy assignment method. */ 562 int assignCopy(const char *a_pszThat); 547 563 548 564 /* Overridden methods: */ 549 virtual voidresetToDefault() RT_OVERRIDE;565 virtual int resetToDefault() RT_OVERRIDE; 550 566 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 551 567 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE; … … 572 588 573 589 /* Overridden methods: */ 574 virtual voidresetToDefault() RT_OVERRIDE;590 virtual int resetToDefault() RT_OVERRIDE; 575 591 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 576 592 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE; … … 718 734 } 719 735 736 /** Safe copy assignment method. */ 737 int assignCopy(RTCRestArray const &a_rThat) 738 { 739 return copyArrayWorker(a_rThat, false /*fThrow*/); 740 } 741 720 742 virtual const char *getType(void) RT_OVERRIDE 721 743 { … … 759 781 int insertCopy(size_t a_idx, ElementType const &a_rThat) 760 782 { 761 return insertCopyWorker(a_idx, &a_rThat, false /*a_fReplace*/);783 return insertCopyWorker(a_idx, a_rThat, false /*a_fReplace*/); 762 784 } 763 785 … … 783 805 int appendCopy(ElementType const &a_rThat) 784 806 { 785 return insertCopyWorker(~(size_t)0, &a_rThat, false /*a_fReplace*/);807 return insertCopyWorker(~(size_t)0, a_rThat, false /*a_fReplace*/); 786 808 } 787 809 … … 807 829 int prependCopy(ElementType const &a_rThat) 808 830 { 809 return insertCopyWorker(0, &a_rThat, false /*a_fReplace*/);831 return insertCopyWorker(0, a_rThat, false /*a_fReplace*/); 810 832 } 811 833 … … 833 855 int replaceCopy(size_t a_idx, ElementType const &a_rThat) 834 856 { 835 return insertCopyWorker(a_idx, &a_rThat, true /*a_fReplace*/);857 return insertCopyWorker(a_idx, a_rThat, true /*a_fReplace*/); 836 858 } 837 859 … … 907 929 virtual RTCRestObjectBase *createValueCopy(RTCRestObjectBase const *a_pSrc) RT_OVERRIDE 908 930 { 909 return new (std::nothrow) ElementType(*(ElementType const *)a_pSrc); 931 ElementType *pCopy = new (std::nothrow) ElementType(); 932 if (pCopy) 933 { 934 int rc = pCopy->assignCopy(*(ElementType const *)a_pSrc); 935 if (RT_SUCCESS(rc)) 936 return pCopy; 937 delete pCopy; 938 } 939 return NULL; 910 940 } 911 941 }; … … 928 958 929 959 /* Overridden methods: */ 930 virtual voidresetToDefault() RT_OVERRIDE;960 virtual int resetToDefault() RT_OVERRIDE; 931 961 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 932 962 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE; … … 1098 1128 } 1099 1129 1130 /** Safe copy assignment method. */ 1131 int assignCopy(RTCRestStringMap const &a_rThat) 1132 { 1133 return copyMapWorker(a_rThat, false /*a_fThrow*/); 1134 } 1135 1100 1136 virtual const char *getType(void) RT_OVERRIDE 1101 1137 { … … 1225 1261 virtual RTCRestObjectBase *createValueCopy(RTCRestObjectBase const *a_pSrc) RT_OVERRIDE 1226 1262 { 1227 return new (std::nothrow) ValueType(*(ValueType const *)a_pSrc); 1263 ValueType *pCopy = new (std::nothrow) ValueType(); 1264 if (pCopy) 1265 { 1266 int rc = pCopy->assignCopy(*(ValueType const *)a_pSrc); 1267 if (RT_SUCCESS(rc)) 1268 return pCopy; 1269 delete pCopy; 1270 } 1271 return NULL; 1228 1272 } 1229 1273 }; … … 1241 1285 /** Default destructor. */ 1242 1286 RTCRestObject(); 1243 /** Copy constructor. */1244 RTCRestObject(RTCRestBool const &a_rThat);1245 1287 /** Destructor. */ 1246 1288 virtual ~RTCRestObject(); 1289 1290 /** Copy constructor. */ 1291 RTCRestObject(RTCRestObject const &a_rThat); 1247 1292 /** Copy assignment operator. */ 1248 RTCRestBool &operator=(RTCRestObject const &a_rThat); 1293 RTCRestObject &operator=(RTCRestObject const &a_rThat); 1294 /** Safe Safe copy assignment method. */ 1295 int assignCopy(RTCRestObject const &a_rThat); 1249 1296 1250 1297 /* Overridden methods: */ 1251 virtual voidresetToDefault() RT_OVERRIDE;1298 virtual int resetToDefault() RT_OVERRIDE; 1252 1299 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_OVERRIDE; 1253 1300 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_OVERRIDE; … … 1273 1320 RTCRestClientRequestBase(); 1274 1321 virtual ~RTCRestClientRequestBase(); 1322 RTCRestClientRequestBase(RTCRestClientRequestBase const &a_rThat); 1323 RTCRestClientRequestBase &operator=(RTCRestClientRequestBase const &a_rThat); 1275 1324 1276 1325 /** 1277 1326 * Reset all members to default values. 1278 */ 1279 virtual void resetToDefault() = 0; 1327 * @returns IPRT status code. 1328 */ 1329 virtual int resetToDefault() = 0; 1280 1330 1281 1331 /** … … 1298 1348 virtual void xmitComplete(int a_rcStatus, RTHTTP a_hHttp) const = 0; 1299 1349 1350 /** 1351 * Checks if there are were any assignment errors. 1352 */ 1353 bool hasAssignmentErrors() const { return m_fErrorSet != 0; } 1354 1300 1355 protected: 1356 /** Set of fields that have been explicitly assigned a value. */ 1357 uint64_t m_fIsSet; 1358 /** Set of fields where value assigning failed. */ 1359 uint64_t m_fErrorSet; 1360 1301 1361 /** Path replacement entry. */ 1302 1362 typedef struct … … 1591 1651 * @param a_enmHttpMethod The HTTP request method. 1592 1652 * @param a_pResponse Pointer to the response object. 1653 * @param a_pszMethod The method name, for logging purposes. 1593 1654 */ 1594 1655 virtual void doCall(RTCRestClientRequestBase const &a_rRequest, RTHTTPMETHOD a_enmHttpMethod, 1595 RTCRestClientResponseBase *a_pResponse );1656 RTCRestClientResponseBase *a_pResponse, const char *a_pszMethod); 1596 1657 1597 1658 };
Note:
See TracChangeset
for help on using the changeset viewer.