- Timestamp:
- Aug 27, 2018 10:15:30 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/cpp/ministring.h
r73907 r73908 586 586 587 587 /** 588 * Appends the output of the string format operation (RTStrPrintf). 589 * 590 * @param pszFormat Pointer to the format string, 591 * @see pg_rt_str_format. 592 * @param ... Ellipsis containing the arguments specified by 593 * the format string. 594 * 595 * @throws std::bad_alloc On allocation error. The object is left unchanged. 596 * 597 * @returns Reference to the object. 598 */ 599 RTCString &appendPrintf(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2); 600 601 /** 602 * Appends the output of the string format operation (RTStrPrintf). 603 * 604 * @param pszFormat Pointer to the format string, 605 * @see pg_rt_str_format. 606 * @param ... Ellipsis containing the arguments specified by 607 * the format string. 608 * 609 * @returns VINF_SUCCESS or VERR_NO_STRING_MEMORY. 610 */ 611 int appendPrintfNoThrow(const char *pszFormat, ...) RT_NOEXCEPT RT_IPRT_FORMAT_ATTR(1, 2); 612 613 /** 614 * Appends the output of the string format operation (RTStrPrintfV). 615 * 616 * @param pszFormat Pointer to the format string, 617 * @see pg_rt_str_format. 618 * @param va Argument vector containing the arguments 619 * specified by the format string. 620 * 621 * @throws std::bad_alloc On allocation error. The object is left unchanged. 622 * 623 * @returns Reference to the object. 624 */ 625 RTCString &appendPrintfV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0); 626 627 /** 628 * Assigns the output of the string format operation (RTStrPrintfV). 629 * 630 * @param pszFormat Pointer to the format string, 631 * @see pg_rt_str_format. 632 * @param va Argument vector containing the arguments 633 * specified by the format string. 634 * 635 * @returns VINF_SUCCESS or VERR_NO_STRING_MEMORY. 636 */ 637 int appendPrintfVNoThrow(const char *pszFormat, va_list va) RT_NOEXCEPT RT_IPRT_FORMAT_ATTR(1, 0); 638 639 /** 588 640 * Shortcut to append(), RTCString variant. 589 641 * … … 624 676 * @returns Reference to the object. 625 677 */ 626 RTCString &toUpper() 678 RTCString &toUpper() RT_NOEXCEPT 627 679 { 628 680 if (length()) … … 643 695 * @returns Reference to the object. 644 696 */ 645 RTCString &toLower() 697 RTCString &toLower() RT_NOEXCEPT 646 698 { 647 699 if (length()) … … 664 716 * @param cchLength How much following @a offStart to erase. 665 717 */ 666 RTCString &erase(size_t offStart = 0, size_t cchLength = npos) ;718 RTCString &erase(size_t offStart = 0, size_t cchLength = npos) RT_NOEXCEPT; 667 719 668 720 /** … … 800 852 * @returns char at the index or null. 801 853 */ 802 inline char operator[](size_t i) const 854 inline char operator[](size_t i) const RT_NOEXCEPT 803 855 { 804 856 if (i < length()) … … 815 867 * @returns const pointer to C-style string. 816 868 */ 817 inline const char *c_str() const 869 inline const char *c_str() const RT_NOEXCEPT 818 870 { 819 871 return (m_psz) ? m_psz : ""; … … 832 884 * may go nowhere. Better not use mutableRaw() at all. 833 885 */ 834 char *mutableRaw() 886 char *mutableRaw() RT_NOEXCEPT 835 887 { 836 888 return m_psz; … … 845 897 * nowhere. 846 898 */ 847 void jolt() 899 void jolt() RT_NOEXCEPT 848 900 { 849 901 if (m_psz) … … 869 921 * @returns @c true if empty, @c false if not. 870 922 */ 871 bool isEmpty() const 923 bool isEmpty() const RT_NOEXCEPT 872 924 { 873 925 return length() == 0; … … 884 936 * @returns @c false if empty, @c true if not. 885 937 */ 886 bool isNotEmpty() const 938 bool isNotEmpty() const RT_NOEXCEPT 887 939 { 888 940 return length() != 0; … … 904 956 * if larger. 905 957 */ 906 int compare(const char *pcszThat, CaseSensitivity cs = CaseSensitive) const 958 int compare(const char *pcszThat, CaseSensitivity cs = CaseSensitive) const RT_NOEXCEPT 907 959 { 908 960 /* This klugde is for m_cch=0 and m_psz=NULL. pcsz=NULL and psz="" … … 924 976 * if larger. 925 977 */ 926 int compare(const RTCString &rThat, CaseSensitivity cs = CaseSensitive) const 978 int compare(const RTCString &rThat, CaseSensitivity cs = CaseSensitive) const RT_NOEXCEPT 927 979 { 928 980 if (cs == CaseSensitive) … … 937 989 * @param rThat The string to compare with. 938 990 */ 939 bool equals(const RTCString &rThat) const 991 bool equals(const RTCString &rThat) const RT_NOEXCEPT 940 992 { 941 993 return rThat.length() == length() … … 950 1002 * @param pszThat The string to compare with. 951 1003 */ 952 bool equals(const char *pszThat) const 1004 bool equals(const char *pszThat) const RT_NOEXCEPT 953 1005 { 954 1006 /* This klugde is for m_cch=0 and m_psz=NULL. pcsz=NULL and psz="" … … 965 1017 * @param that The string to compare with. 966 1018 */ 967 bool equalsIgnoreCase(const RTCString &that) const 1019 bool equalsIgnoreCase(const RTCString &that) const RT_NOEXCEPT 968 1020 { 969 1021 /* Unfolded upper and lower case characters may require different … … 978 1030 * @param pszThat The string to compare with. 979 1031 */ 980 bool equalsIgnoreCase(const char *pszThat) const 1032 bool equalsIgnoreCase(const char *pszThat) const RT_NOEXCEPT 981 1033 { 982 1034 /* This klugde is for m_cch=0 and m_psz=NULL. pcsz=NULL and psz="" … … 1020 1072 * @returns 0 based position of pszNeedle. npos if not found. 1021 1073 */ 1022 size_t find(const char *pszNeedle, size_t offStart = 0) const ;1074 size_t find(const char *pszNeedle, size_t offStart = 0) const RT_NOEXCEPT; 1023 1075 1024 1076 /** … … 1036 1088 * NULL or an empty string. 1037 1089 */ 1038 size_t find(const RTCString *pStrNeedle, size_t offStart = 0) const ;1090 size_t find(const RTCString *pStrNeedle, size_t offStart = 0) const RT_NOEXCEPT; 1039 1091 1040 1092 /** … … 1046 1098 * @param chReplace Character to replace cFind with. Must be ASCII < 128. 1047 1099 */ 1048 void findReplace(char chFind, char chReplace) ;1100 void findReplace(char chFind, char chReplace) RT_NOEXCEPT; 1049 1101 1050 1102 /** … … 1054 1106 * @remarks QString::count 1055 1107 */ 1056 size_t count(char ch) const ;1108 size_t count(char ch) const RT_NOEXCEPT; 1057 1109 1058 1110 /** … … 1063 1115 * @remarks QString::count 1064 1116 */ 1065 size_t count(const char *psz, CaseSensitivity cs = CaseSensitive) const ;1117 size_t count(const char *psz, CaseSensitivity cs = CaseSensitive) const RT_NOEXCEPT; 1066 1118 1067 1119 /** … … 1072 1124 * @remarks QString::count 1073 1125 */ 1074 size_t count(const RTCString *pStr, CaseSensitivity cs = CaseSensitive) const ;1126 size_t count(const RTCString *pStr, CaseSensitivity cs = CaseSensitive) const RT_NOEXCEPT; 1075 1127 1076 1128 /** … … 1079 1131 * @returns this 1080 1132 */ 1081 RTCString &strip() ;1133 RTCString &strip() RT_NOEXCEPT; 1082 1134 1083 1135 /** … … 1086 1138 * @returns this 1087 1139 */ 1088 RTCString &stripLeft() ;1140 RTCString &stripLeft() RT_NOEXCEPT; 1089 1141 1090 1142 /** … … 1093 1145 * @returns this 1094 1146 */ 1095 RTCString &stripRight() ;1147 RTCString &stripRight() RT_NOEXCEPT; 1096 1148 1097 1149 /** … … 1135 1187 * @returns true if match, false if mismatch. 1136 1188 */ 1137 bool endsWith(const RTCString &that, CaseSensitivity cs = CaseSensitive) const ;1189 bool endsWith(const RTCString &that, CaseSensitivity cs = CaseSensitive) const RT_NOEXCEPT; 1138 1190 1139 1191 /** … … 1143 1195 * @returns true if match, false if mismatch. 1144 1196 */ 1145 bool startsWith(const RTCString &that, CaseSensitivity cs = CaseSensitive) const ;1197 bool startsWith(const RTCString &that, CaseSensitivity cs = CaseSensitive) const RT_NOEXCEPT; 1146 1198 1147 1199 /** … … 1152 1204 * @returns true if match, false if mismatch. 1153 1205 */ 1154 bool startsWithWord(const char *pszWord, CaseSensitivity enmCase = CaseSensitive) const ;1206 bool startsWithWord(const char *pszWord, CaseSensitivity enmCase = CaseSensitive) const RT_NOEXCEPT; 1155 1207 1156 1208 /** … … 1161 1213 * @returns true if match, false if mismatch. 1162 1214 */ 1163 bool startsWithWord(const RTCString &rThat, CaseSensitivity enmCase = CaseSensitive) const ;1215 bool startsWithWord(const RTCString &rThat, CaseSensitivity enmCase = CaseSensitive) const RT_NOEXCEPT; 1164 1216 1165 1217 /** … … 1170 1222 * @returns true if found, false if not found. 1171 1223 */ 1172 bool contains(const RTCString &that, CaseSensitivity cs = CaseSensitive) const ;1224 bool contains(const RTCString &that, CaseSensitivity cs = CaseSensitive) const RT_NOEXCEPT; 1173 1225 1174 1226 /** … … 1179 1231 * @returns true if found, false if not found. 1180 1232 */ 1181 bool contains(const char *pszNeedle, CaseSensitivity cs = CaseSensitive) const ;1233 bool contains(const char *pszNeedle, CaseSensitivity cs = CaseSensitive) const RT_NOEXCEPT; 1182 1234 1183 1235 /** … … 1187 1239 * @returns 0 on failure. 1188 1240 */ 1189 int32_t toInt32() const 1241 int32_t toInt32() const RT_NOEXCEPT 1190 1242 { 1191 1243 return RTStrToInt32(c_str()); … … 1198 1250 * @returns 0 on failure. 1199 1251 */ 1200 uint32_t toUInt32() const 1252 uint32_t toUInt32() const RT_NOEXCEPT 1201 1253 { 1202 1254 return RTStrToUInt32(c_str()); … … 1209 1261 * @returns 0 on failure. 1210 1262 */ 1211 int64_t toInt64() const 1263 int64_t toInt64() const RT_NOEXCEPT 1212 1264 { 1213 1265 return RTStrToInt64(c_str()); … … 1220 1272 * @returns 0 on failure. 1221 1273 */ 1222 uint64_t toUInt64() const 1274 uint64_t toUInt64() const RT_NOEXCEPT 1223 1275 { 1224 1276 return RTStrToUInt64(c_str()); … … 1231 1283 * @returns IPRT error code, see RTStrToInt64. 1232 1284 */ 1233 int toInt(uint64_t &i) const ;1285 int toInt(uint64_t &i) const RT_NOEXCEPT; 1234 1286 1235 1287 /** … … 1239 1291 * @returns IPRT error code, see RTStrToInt32. 1240 1292 */ 1241 int toInt(uint32_t &i) const ;1293 int toInt(uint32_t &i) const RT_NOEXCEPT; 1242 1294 1243 1295 /** Splitting behavior regarding empty sections in the string. */ … … 1254 1306 * @param a_enmMode How should empty parts be handled. 1255 1307 * @returns separated strings as string list. 1308 * @throws std::bad_alloc On allocation error. 1256 1309 */ 1257 1310 RTCList<RTCString, RTCString *> split(const RTCString &a_rstrSep, … … 1266 1319 * @param a_rstrSep The separator used for joining. 1267 1320 * @returns joined string. 1321 * @throws std::bad_alloc On allocation error. 1268 1322 */ 1269 1323 static RTCString joinEx(const RTCList<RTCString, RTCString *> &a_rList, … … 1277 1331 * @param a_rstrSep The separator used for joining. 1278 1332 * @returns joined string. 1333 * @throws std::bad_alloc On allocation error. 1279 1334 */ 1280 1335 static RTCString join(const RTCList<RTCString, RTCString *> &a_rList, … … 1288 1343 * @param a_rThat The string to swap with. 1289 1344 */ 1290 inline void swap(RTCString &a_rThat) throw()1345 inline void swap(RTCString &a_rThat) RT_NOEXCEPT 1291 1346 { 1292 1347 char *pszTmp = m_psz; … … 1314 1369 * assigning a new string. 1315 1370 */ 1316 void cleanup() 1371 void cleanup() RT_NOEXCEPT 1317 1372 { 1318 1373 if (m_psz) -
trunk/src/VBox/Runtime/common/string/ministring.cpp
r73907 r73908 283 283 } 284 284 285 RTCString &RTCString::appendPrintfV(const char *pszFormat, va_list va) 286 { 287 RTStrFormatV(printfOutputCallback, this, NULL, NULL, pszFormat, va); 288 return *this; 289 } 290 285 291 struct RTCSTRINGOTHROW 286 292 { … … 338 344 } 339 345 346 int RTCString::appendPrintfVNoThrow(const char *pszFormat, va_list va) RT_NOEXCEPT 347 { 348 RTCSTRINGOTHROW Args = { this, VINF_SUCCESS }; 349 RTStrFormatV(printfOutputCallback, &Args, NULL, NULL, pszFormat, va); 350 return Args.rc; 351 } 352 353 RTCString &RTCString::appendPrintf(const char *pszFormat, ...) 354 { 355 va_list va; 356 va_start(va, pszFormat); 357 appendPrintfV(pszFormat, va); 358 va_end(va); 359 return *this; 360 } 361 362 int RTCString::appendPrintfNoThrow(const char *pszFormat, ...) RT_NOEXCEPT 363 { 364 va_list va; 365 va_start(va, pszFormat); 366 int rc = appendPrintfVNoThrow(pszFormat, va); 367 va_end(va); 368 return rc; 369 } 370 340 371 RTCString &RTCString::append(const RTCString &that) 341 372 { … … 538 569 } 539 570 540 541 RTCString &RTCString::erase(size_t offStart /*= 0*/, size_t cchLength /*= npos*/) 571 RTCString &RTCString::erase(size_t offStart /*= 0*/, size_t cchLength /*= npos*/) RT_NOEXCEPT 542 572 { 543 573 size_t cch = length(); … … 592 622 593 623 int RTCString::replaceNoThrow(size_t offStart, size_t cchLength, const RTCString &rStrReplacement, 594 size_t offReplacement, size_t cchReplacement) 624 size_t offReplacement, size_t cchReplacement) RT_NOEXCEPT 595 625 { 596 626 Assert(this != &rStrReplacement); … … 713 743 714 744 715 size_t RTCString::find(const char *pszNeedle, size_t offStart /*= 0*/) const 745 size_t RTCString::find(const char *pszNeedle, size_t offStart /*= 0*/) const RT_NOEXCEPT 716 746 { 717 747 if (offStart < length()) … … 732 762 } 733 763 734 size_t RTCString::find(const RTCString *pStrNeedle, size_t offStart /*= 0*/) const 764 size_t RTCString::find(const RTCString *pStrNeedle, size_t offStart /*= 0*/) const RT_NOEXCEPT 735 765 { 736 766 if (offStart < length()) … … 755 785 } 756 786 757 void RTCString::findReplace(char chFind, char chReplace) 787 void RTCString::findReplace(char chFind, char chReplace) RT_NOEXCEPT 758 788 { 759 789 Assert((unsigned int)chFind < 128U); … … 768 798 } 769 799 770 size_t RTCString::count(char ch) const 800 size_t RTCString::count(char ch) const RT_NOEXCEPT 771 801 { 772 802 Assert((unsigned int)ch < 128U); … … 785 815 786 816 #if 0 /** @todo implement these when needed. */ 787 size_t RTCString::count(const char *psz, CaseSensitivity cs = CaseSensitive) const 788 { 789 } 790 791 size_t RTCString::count(const RTCString *pStr, CaseSensitivity cs = CaseSensitive) const 817 size_t RTCString::count(const char *psz, CaseSensitivity cs = CaseSensitive) const RT_NOEXCEPT 818 { 819 } 820 821 size_t RTCString::count(const RTCString *pStr, CaseSensitivity cs = CaseSensitive) const RT_NOEXCEPT 792 822 { 793 823 … … 796 826 797 827 798 RTCString &RTCString::strip() 828 RTCString &RTCString::strip() RT_NOEXCEPT 799 829 { 800 830 stripRight(); … … 803 833 804 834 805 RTCString &RTCString::stripLeft() 835 RTCString &RTCString::stripLeft() RT_NOEXCEPT 806 836 { 807 837 char *psz = m_psz; … … 824 854 825 855 826 RTCString &RTCString::stripRight() 856 RTCString &RTCString::stripRight() RT_NOEXCEPT 827 857 { 828 858 char *psz = m_psz; … … 888 918 } 889 919 890 bool RTCString::endsWith(const RTCString &that, CaseSensitivity cs /*= CaseSensitive*/) const 920 bool RTCString::endsWith(const RTCString &that, CaseSensitivity cs /*= CaseSensitive*/) const RT_NOEXCEPT 891 921 { 892 922 size_t l1 = length(); … … 906 936 } 907 937 908 bool RTCString::startsWith(const RTCString &that, CaseSensitivity cs /*= CaseSensitive*/) const 938 bool RTCString::startsWith(const RTCString &that, CaseSensitivity cs /*= CaseSensitive*/) const RT_NOEXCEPT 909 939 { 910 940 size_t l1 = length(); … … 921 951 } 922 952 923 bool RTCString::startsWithWord(const char *pszWord, CaseSensitivity enmCase /*= CaseSensitive*/) const 953 bool RTCString::startsWithWord(const char *pszWord, CaseSensitivity enmCase /*= CaseSensitive*/) const RT_NOEXCEPT 924 954 { 925 955 const char *pszSrc = RTStrStripL(c_str()); /** @todo RTStrStripL doesn't use RTUniCpIsSpace (nbsp) */ … … 940 970 } 941 971 942 bool RTCString::startsWithWord(const RTCString &rThat, CaseSensitivity enmCase /*= CaseSensitive*/) const 972 bool RTCString::startsWithWord(const RTCString &rThat, CaseSensitivity enmCase /*= CaseSensitive*/) const RT_NOEXCEPT 943 973 { 944 974 return startsWithWord(rThat.c_str(), enmCase); 945 975 } 946 976 947 bool RTCString::contains(const RTCString &that, CaseSensitivity cs /*= CaseSensitive*/) const 977 bool RTCString::contains(const RTCString &that, CaseSensitivity cs /*= CaseSensitive*/) const RT_NOEXCEPT 948 978 { 949 979 /** @todo r-bird: Not checking for NULL strings like startsWith does (and … … 954 984 } 955 985 956 bool RTCString::contains(const char *pszNeedle, CaseSensitivity cs /*= CaseSensitive*/) const 986 bool RTCString::contains(const char *pszNeedle, CaseSensitivity cs /*= CaseSensitive*/) const RT_NOEXCEPT 957 987 { 958 988 /** @todo r-bird: Not checking for NULL strings like startsWith does (and … … 963 993 } 964 994 965 int RTCString::toInt(uint64_t &i) const 995 int RTCString::toInt(uint64_t &i) const RT_NOEXCEPT 966 996 { 967 997 if (!m_psz) … … 970 1000 } 971 1001 972 int RTCString::toInt(uint32_t &i) const 1002 int RTCString::toInt(uint32_t &i) const RT_NOEXCEPT 973 1003 { 974 1004 if (!m_psz)
Note:
See TracChangeset
for help on using the changeset viewer.