vbox的更動 62021 路徑 trunk/src/VBox/Runtime
- 時間撮記:
- 2016-7-5 上午09:34:17 (8 年 以前)
- 位置:
- trunk/src/VBox/Runtime
- 檔案:
-
- 修改 2 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Runtime/common/misc/json.cpp
r61760 r62021 201 201 { 202 202 /** Number of elements in the array. */ 203 u int32_tcItems;203 unsigned cItems; 204 204 /** Pointer to the array of items. */ 205 205 PRTJSONVALINT *papItems; … … 209 209 { 210 210 /** Number of members. */ 211 u int32_tcMembers;211 unsigned cMembers; 212 212 /** Pointer to the array holding the member names. */ 213 213 char **papszNames; … … 1264 1264 } 1265 1265 1266 RTDECL(int) RTJsonValue GetStringEx(RTJSONVAL hJsonVal, const char **ppszStr)1266 RTDECL(int) RTJsonValueQueryString(RTJSONVAL hJsonVal, const char **ppszStr) 1267 1267 { 1268 1268 PRTJSONVALINT pThis = hJsonVal; … … 1275 1275 } 1276 1276 1277 RTDECL(int) RTJsonValue GetNumber(RTJSONVAL hJsonVal, int64_t *pi64Num)1277 RTDECL(int) RTJsonValueQueryInteger(RTJSONVAL hJsonVal, int64_t *pi64Num) 1278 1278 { 1279 1279 PRTJSONVALINT pThis = hJsonVal; … … 1286 1286 } 1287 1287 1288 RTDECL(int) RTJsonValue GetByName(RTJSONVAL hJsonVal, const char *pszName, PRTJSONVAL phJsonVal)1288 RTDECL(int) RTJsonValueQueryByName(RTJSONVAL hJsonVal, const char *pszName, PRTJSONVAL phJsonVal) 1289 1289 { 1290 1290 PRTJSONVALINT pThis = hJsonVal; … … 1309 1309 } 1310 1310 1311 RTDECL(int) RTJsonValue GetNumberByName(RTJSONVAL hJsonVal, const char *pszName, int64_t *pi64Num)1311 RTDECL(int) RTJsonValueQueryIntegerByName(RTJSONVAL hJsonVal, const char *pszName, int64_t *pi64Num) 1312 1312 { 1313 1313 RTJSONVAL hJsonValNum = NIL_RTJSONVAL; 1314 int rc = RTJsonValue GetByName(hJsonVal, pszName, &hJsonValNum);1314 int rc = RTJsonValueQueryByName(hJsonVal, pszName, &hJsonValNum); 1315 1315 if (RT_SUCCESS(rc)) 1316 1316 { 1317 rc = RTJsonValue GetNumber(hJsonValNum, pi64Num);1317 rc = RTJsonValueQueryInteger(hJsonValNum, pi64Num); 1318 1318 RTJsonValueRelease(hJsonValNum); 1319 1319 } … … 1322 1322 } 1323 1323 1324 RTDECL(int) RTJsonValue GetStringByName(RTJSONVAL hJsonVal, const char *pszName, char **ppszStr)1324 RTDECL(int) RTJsonValueQueryStringByName(RTJSONVAL hJsonVal, const char *pszName, char **ppszStr) 1325 1325 { 1326 1326 RTJSONVAL hJsonValStr = NIL_RTJSONVAL; 1327 int rc = RTJsonValue GetByName(hJsonVal, pszName, &hJsonValStr);1327 int rc = RTJsonValueQueryByName(hJsonVal, pszName, &hJsonValStr); 1328 1328 if (RT_SUCCESS(rc)) 1329 1329 { 1330 1330 const char *pszStr = NULL; 1331 rc = RTJsonValue GetStringEx(hJsonValStr, &pszStr);1331 rc = RTJsonValueQueryString(hJsonValStr, &pszStr); 1332 1332 if (RT_SUCCESS(rc)) 1333 1333 { … … 1342 1342 } 1343 1343 1344 RTDECL(int) RTJsonValue GetBooleanByName(RTJSONVAL hJsonVal, const char *pszName, bool *pfBoolean)1344 RTDECL(int) RTJsonValueQueryBooleanByName(RTJSONVAL hJsonVal, const char *pszName, bool *pfBoolean) 1345 1345 { 1346 1346 AssertPtrReturn(pfBoolean, VERR_INVALID_POINTER); 1347 1347 1348 1348 RTJSONVAL hJsonValBool = NIL_RTJSONVAL; 1349 int rc = RTJsonValue GetByName(hJsonVal, pszName, &hJsonValBool);1349 int rc = RTJsonValueQueryByName(hJsonVal, pszName, &hJsonValBool); 1350 1350 if (RT_SUCCESS(rc)) 1351 1351 { … … 1363 1363 } 1364 1364 1365 RTDECL(u int32_t) RTJsonValueGetArraySize(RTJSONVAL hJsonVal)1365 RTDECL(unsigned) RTJsonValueGetArraySize(RTJSONVAL hJsonVal) 1366 1366 { 1367 1367 PRTJSONVALINT pThis = hJsonVal; … … 1372 1372 } 1373 1373 1374 RTDECL(int) RTJsonValue GetArraySizeEx(RTJSONVAL hJsonVal, uint32_t*pcItems)1374 RTDECL(int) RTJsonValueQueryArraySize(RTJSONVAL hJsonVal, unsigned *pcItems) 1375 1375 { 1376 1376 PRTJSONVALINT pThis = hJsonVal; … … 1383 1383 } 1384 1384 1385 RTDECL(int) RTJsonValue GetByIndex(RTJSONVAL hJsonVal, uint32_tidx, PRTJSONVAL phJsonVal)1385 RTDECL(int) RTJsonValueQueryByIndex(RTJSONVAL hJsonVal, unsigned idx, PRTJSONVAL phJsonVal) 1386 1386 { 1387 1387 PRTJSONVALINT pThis = hJsonVal; … … 1416 1416 } 1417 1417 1418 RTDECL(int) RTJsonIterator GetValue(RTJSONIT hJsonIt, PRTJSONVAL phJsonVal, const char **ppszName)1418 RTDECL(int) RTJsonIteratorQueryValue(RTJSONIT hJsonIt, PRTJSONVAL phJsonVal, const char **ppszName) 1419 1419 { 1420 1420 PRTJSONITINT pIt = hJsonIt; -
trunk/src/VBox/Runtime/testcase/tstRTJson.cpp
r61730 r62021 101 101 static void tstCorrectnessRcForInvalidType(RTTEST hTest, RTJSONVAL hJsonVal, RTJSONVALTYPE enmType) 102 102 { 103 #if 0 /* Enable manuallyor it will assert all over the place for debug builds. */103 #ifndef RT_STRICT /* Enable manually if assertions are enabled or it will assert all over the place for debug builds. */ 104 104 if ( enmType != RTJSONVALTYPE_OBJECT 105 105 && enmType != RTJSONVALTYPE_ARRAY) … … 116 116 RTJSONVAL hJsonValItem = NIL_RTJSONVAL; 117 117 RTTEST_CHECK(hTest, RTJsonValueGetArraySize(hJsonVal) == 0); 118 RTTEST_CHECK_RC(hTest, RTJsonValue GetArraySizeEx(hJsonVal, &cItems), VERR_JSON_VALUE_INVALID_TYPE);119 RTTEST_CHECK_RC(hTest, RTJsonValue GetByIndex(hJsonVal, 0, &hJsonValItem), VERR_JSON_VALUE_INVALID_TYPE);118 RTTEST_CHECK_RC(hTest, RTJsonValueQueryArraySize(hJsonVal, &cItems), VERR_JSON_VALUE_INVALID_TYPE); 119 RTTEST_CHECK_RC(hTest, RTJsonValueQueryByIndex(hJsonVal, 0, &hJsonValItem), VERR_JSON_VALUE_INVALID_TYPE); 120 120 } 121 121 … … 124 124 /* The object access methods should return errors. */ 125 125 RTJSONVAL hJsonValMember = NIL_RTJSONVAL; 126 RTTEST_CHECK_RC(hTest, RTJsonValue GetByName(hJsonVal, "test", &hJsonValMember), VERR_JSON_VALUE_INVALID_TYPE);126 RTTEST_CHECK_RC(hTest, RTJsonValueQueryByName(hJsonVal, "test", &hJsonValMember), VERR_JSON_VALUE_INVALID_TYPE); 127 127 } 128 128 … … 130 130 { 131 131 int64_t i64Num = 0; 132 RTTEST_CHECK_RC(hTest, RTJsonValue GetNumber(hJsonVal, &i64Num), VERR_JSON_VALUE_INVALID_TYPE);132 RTTEST_CHECK_RC(hTest, RTJsonValueQueryInteger(hJsonVal, &i64Num), VERR_JSON_VALUE_INVALID_TYPE); 133 133 } 134 134 … … 137 137 const char *psz = NULL; 138 138 RTTEST_CHECK(hTest, RTJsonValueGetString(hJsonVal) == NULL); 139 RTTEST_CHECK_RC(hTest, RTJsonValue GetStringEx(hJsonVal, &psz), VERR_JSON_VALUE_INVALID_TYPE);139 RTTEST_CHECK_RC(hTest, RTJsonValueQueryString(hJsonVal, &psz), VERR_JSON_VALUE_INVALID_TYPE); 140 140 } 141 141 #endif … … 149 149 uint32_t cItems = 0; 150 150 RTTEST_CHECK(hTest, RTJsonValueGetArraySize(hJsonVal) == 6); 151 RTTEST_CHECK_RC_OK(hTest, RTJsonValueGetArraySizeEx(hJsonVal, &cItems)); 151 RTTEST_CHECK_RC_OK(hTest, RTJsonValueQueryArraySize(hJsonVal, &cItems)); 152 RTTEST_CHECK(hTest, cItems == RTJsonValueGetArraySize(hJsonVal)); 152 153 153 154 for (uint32_t i = 1; i <= 5; i++) … … 155 156 int64_t i64Num = 0; 156 157 RTJSONVAL hJsonValItem = NIL_RTJSONVAL; 157 RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValue GetByIndex(hJsonVal, i - 1, &hJsonValItem));158 RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueQueryByIndex(hJsonVal, i - 1, &hJsonValItem)); 158 159 RTTEST_CHECK(hTest, RTJsonValueGetType(hJsonValItem) == RTJSONVALTYPE_NUMBER); 159 RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValue GetNumber(hJsonValItem, &i64Num));160 RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueQueryInteger(hJsonValItem, &i64Num)); 160 161 RTTEST_CHECK(hTest, i64Num == (int64_t)i); 161 162 RTTEST_CHECK(hTest, RTJsonValueRelease(hJsonValItem) == 1); … … 165 166 const char *pszStr = NULL; 166 167 RTJSONVAL hJsonValItem = NIL_RTJSONVAL; 167 RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValue GetByIndex(hJsonVal, 5, &hJsonValItem));168 RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueQueryByIndex(hJsonVal, 5, &hJsonValItem)); 168 169 RTTEST_CHECK(hTest, RTJsonValueGetType(hJsonValItem) == RTJSONVALTYPE_STRING); 169 RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValue GetStringEx(hJsonValItem, &pszStr));170 RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueQueryString(hJsonValItem, &pszStr)); 170 171 RTTEST_CHECK(hTest, RTJsonValueGetString(hJsonValItem) == pszStr); 171 172 RTTEST_CHECK(hTest, strcmp(pszStr, "6") == 0); … … 185 186 const char *pszName = NULL; 186 187 RTJSONVAL hJsonValMember = NIL_RTJSONVAL; 187 rc = RTJsonIterator GetValue(hJsonIt, &hJsonValMember, &pszName);188 rc = RTJsonIteratorQueryValue(hJsonIt, &hJsonValMember, &pszName); 188 189 RTTEST_CHECK(hTest, RT_SUCCESS(rc)); 189 190 RTTEST_CHECK(hTest, pszName != NULL); … … 208 209 RTTEST_CHECK(hTest, strcmp(pszName, "string") == 0); 209 210 const char *pszStr = NULL; 210 RTTEST_CHECK_RC_OK(hTest, RTJsonValue GetStringEx(hJsonValMember, &pszStr));211 RTTEST_CHECK_RC_OK(hTest, RTJsonValueQueryString(hJsonValMember, &pszStr)); 211 212 RTTEST_CHECK(hTest, strcmp(pszStr, "test") == 0); 212 213 break; … … 216 217 RTTEST_CHECK(hTest, strcmp(pszName, "number") == 0); 217 218 int64_t i64Num = 0; 218 RTTEST_CHECK_RC_OK(hTest, RTJsonValue GetNumber(hJsonValMember, &i64Num));219 RTTEST_CHECK_RC_OK(hTest, RTJsonValueQueryInteger(hJsonValMember, &i64Num)); 219 220 RTTEST_CHECK(hTest, i64Num == 100); 220 221 break; … … 237 238 RTTEST_CHECK(hTest, rc == VINF_SUCCESS || rc == VERR_JSON_ITERATOR_END); 238 239 if (RT_SUCCESS(rc)) 239 RTTEST_CHECK_RC_OK(hTest, RTJsonIterator GetValue(hJsonIt, &hJsonValMember, &pszName));240 RTTEST_CHECK_RC_OK(hTest, RTJsonIteratorQueryValue(hJsonIt, &hJsonValMember, &pszName)); 240 241 } 241 242 RTJsonIteratorFree(hJsonIt);
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器