VirtualBox

vbox的更動 62021 路徑 trunk/src/VBox/Runtime


忽略:
時間撮記:
2016-7-5 上午09:34:17 (8 年 以前)
作者:
vboxsync
訊息:

Runtime/RTJson: Fix review todos

位置:
trunk/src/VBox/Runtime
檔案:
修改 2 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Runtime/common/misc/json.cpp

    r61760 r62021  
    201201        {
    202202            /** Number of elements in the array. */
    203             uint32_t        cItems;
     203            unsigned        cItems;
    204204            /** Pointer to the array of items. */
    205205            PRTJSONVALINT   *papItems;
     
    209209        {
    210210            /** Number of members. */
    211             uint32_t        cMembers;
     211            unsigned        cMembers;
    212212            /** Pointer to the array holding the member names. */
    213213            char            **papszNames;
     
    12641264}
    12651265
    1266 RTDECL(int) RTJsonValueGetStringEx(RTJSONVAL hJsonVal, const char **ppszStr)
     1266RTDECL(int) RTJsonValueQueryString(RTJSONVAL hJsonVal, const char **ppszStr)
    12671267{
    12681268    PRTJSONVALINT pThis = hJsonVal;
     
    12751275}
    12761276
    1277 RTDECL(int) RTJsonValueGetNumber(RTJSONVAL hJsonVal, int64_t *pi64Num)
     1277RTDECL(int) RTJsonValueQueryInteger(RTJSONVAL hJsonVal, int64_t *pi64Num)
    12781278{
    12791279    PRTJSONVALINT pThis = hJsonVal;
     
    12861286}
    12871287
    1288 RTDECL(int) RTJsonValueGetByName(RTJSONVAL hJsonVal, const char *pszName, PRTJSONVAL phJsonVal)
     1288RTDECL(int) RTJsonValueQueryByName(RTJSONVAL hJsonVal, const char *pszName, PRTJSONVAL phJsonVal)
    12891289{
    12901290    PRTJSONVALINT pThis = hJsonVal;
     
    13091309}
    13101310
    1311 RTDECL(int) RTJsonValueGetNumberByName(RTJSONVAL hJsonVal, const char *pszName, int64_t *pi64Num)
     1311RTDECL(int) RTJsonValueQueryIntegerByName(RTJSONVAL hJsonVal, const char *pszName, int64_t *pi64Num)
    13121312{
    13131313    RTJSONVAL hJsonValNum = NIL_RTJSONVAL;
    1314     int rc = RTJsonValueGetByName(hJsonVal, pszName, &hJsonValNum);
     1314    int rc = RTJsonValueQueryByName(hJsonVal, pszName, &hJsonValNum);
    13151315    if (RT_SUCCESS(rc))
    13161316    {
    1317         rc = RTJsonValueGetNumber(hJsonValNum, pi64Num);
     1317        rc = RTJsonValueQueryInteger(hJsonValNum, pi64Num);
    13181318        RTJsonValueRelease(hJsonValNum);
    13191319    }
     
    13221322}
    13231323
    1324 RTDECL(int) RTJsonValueGetStringByName(RTJSONVAL hJsonVal, const char *pszName, char **ppszStr)
     1324RTDECL(int) RTJsonValueQueryStringByName(RTJSONVAL hJsonVal, const char *pszName, char **ppszStr)
    13251325{
    13261326    RTJSONVAL hJsonValStr = NIL_RTJSONVAL;
    1327     int rc = RTJsonValueGetByName(hJsonVal, pszName, &hJsonValStr);
     1327    int rc = RTJsonValueQueryByName(hJsonVal, pszName, &hJsonValStr);
    13281328    if (RT_SUCCESS(rc))
    13291329    {
    13301330        const char *pszStr = NULL;
    1331         rc = RTJsonValueGetStringEx(hJsonValStr, &pszStr);
     1331        rc = RTJsonValueQueryString(hJsonValStr, &pszStr);
    13321332        if (RT_SUCCESS(rc))
    13331333        {
     
    13421342}
    13431343
    1344 RTDECL(int) RTJsonValueGetBooleanByName(RTJSONVAL hJsonVal, const char *pszName, bool *pfBoolean)
     1344RTDECL(int) RTJsonValueQueryBooleanByName(RTJSONVAL hJsonVal, const char *pszName, bool *pfBoolean)
    13451345{
    13461346    AssertPtrReturn(pfBoolean, VERR_INVALID_POINTER);
    13471347
    13481348    RTJSONVAL hJsonValBool = NIL_RTJSONVAL;
    1349     int rc = RTJsonValueGetByName(hJsonVal, pszName, &hJsonValBool);
     1349    int rc = RTJsonValueQueryByName(hJsonVal, pszName, &hJsonValBool);
    13501350    if (RT_SUCCESS(rc))
    13511351    {
     
    13631363}
    13641364
    1365 RTDECL(uint32_t) RTJsonValueGetArraySize(RTJSONVAL hJsonVal)
     1365RTDECL(unsigned) RTJsonValueGetArraySize(RTJSONVAL hJsonVal)
    13661366{
    13671367    PRTJSONVALINT pThis = hJsonVal;
     
    13721372}
    13731373
    1374 RTDECL(int) RTJsonValueGetArraySizeEx(RTJSONVAL hJsonVal, uint32_t *pcItems)
     1374RTDECL(int) RTJsonValueQueryArraySize(RTJSONVAL hJsonVal, unsigned *pcItems)
    13751375{
    13761376    PRTJSONVALINT pThis = hJsonVal;
     
    13831383}
    13841384
    1385 RTDECL(int) RTJsonValueGetByIndex(RTJSONVAL hJsonVal, uint32_t idx, PRTJSONVAL phJsonVal)
     1385RTDECL(int) RTJsonValueQueryByIndex(RTJSONVAL hJsonVal, unsigned idx, PRTJSONVAL phJsonVal)
    13861386{
    13871387    PRTJSONVALINT pThis = hJsonVal;
     
    14161416}
    14171417
    1418 RTDECL(int) RTJsonIteratorGetValue(RTJSONIT hJsonIt, PRTJSONVAL phJsonVal, const char **ppszName)
     1418RTDECL(int) RTJsonIteratorQueryValue(RTJSONIT hJsonIt, PRTJSONVAL phJsonVal, const char **ppszName)
    14191419{
    14201420    PRTJSONITINT pIt = hJsonIt;
  • trunk/src/VBox/Runtime/testcase/tstRTJson.cpp

    r61730 r62021  
    101101static void tstCorrectnessRcForInvalidType(RTTEST hTest, RTJSONVAL hJsonVal, RTJSONVALTYPE enmType)
    102102{
    103 #if 0 /* Enable manually or 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. */
    104104    if (   enmType != RTJSONVALTYPE_OBJECT
    105105        && enmType != RTJSONVALTYPE_ARRAY)
     
    116116        RTJSONVAL hJsonValItem = NIL_RTJSONVAL;
    117117        RTTEST_CHECK(hTest, RTJsonValueGetArraySize(hJsonVal) == 0);
    118         RTTEST_CHECK_RC(hTest, RTJsonValueGetArraySizeEx(hJsonVal, &cItems), VERR_JSON_VALUE_INVALID_TYPE);
    119         RTTEST_CHECK_RC(hTest, RTJsonValueGetByIndex(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);
    120120    }
    121121
     
    124124        /* The object access methods should return errors. */
    125125        RTJSONVAL hJsonValMember = NIL_RTJSONVAL;
    126         RTTEST_CHECK_RC(hTest, RTJsonValueGetByName(hJsonVal, "test", &hJsonValMember), VERR_JSON_VALUE_INVALID_TYPE);
     126        RTTEST_CHECK_RC(hTest, RTJsonValueQueryByName(hJsonVal, "test", &hJsonValMember), VERR_JSON_VALUE_INVALID_TYPE);
    127127    }
    128128
     
    130130    {
    131131        int64_t i64Num = 0;
    132         RTTEST_CHECK_RC(hTest, RTJsonValueGetNumber(hJsonVal, &i64Num), VERR_JSON_VALUE_INVALID_TYPE);
     132        RTTEST_CHECK_RC(hTest, RTJsonValueQueryInteger(hJsonVal, &i64Num), VERR_JSON_VALUE_INVALID_TYPE);
    133133    }
    134134
     
    137137        const char *psz = NULL;
    138138        RTTEST_CHECK(hTest, RTJsonValueGetString(hJsonVal) == NULL);
    139         RTTEST_CHECK_RC(hTest, RTJsonValueGetStringEx(hJsonVal, &psz), VERR_JSON_VALUE_INVALID_TYPE);
     139        RTTEST_CHECK_RC(hTest, RTJsonValueQueryString(hJsonVal, &psz), VERR_JSON_VALUE_INVALID_TYPE);
    140140    }
    141141#endif
     
    149149    uint32_t cItems = 0;
    150150    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));
    152153
    153154    for (uint32_t i = 1; i <= 5; i++)
     
    155156        int64_t i64Num = 0;
    156157        RTJSONVAL hJsonValItem = NIL_RTJSONVAL;
    157         RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueGetByIndex(hJsonVal, i - 1, &hJsonValItem));
     158        RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueQueryByIndex(hJsonVal, i - 1, &hJsonValItem));
    158159        RTTEST_CHECK(hTest, RTJsonValueGetType(hJsonValItem) == RTJSONVALTYPE_NUMBER);
    159         RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueGetNumber(hJsonValItem, &i64Num));
     160        RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueQueryInteger(hJsonValItem, &i64Num));
    160161        RTTEST_CHECK(hTest, i64Num == (int64_t)i);
    161162        RTTEST_CHECK(hTest, RTJsonValueRelease(hJsonValItem) == 1);
     
    165166    const char *pszStr = NULL;
    166167    RTJSONVAL hJsonValItem = NIL_RTJSONVAL;
    167     RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueGetByIndex(hJsonVal, 5, &hJsonValItem));
     168    RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueQueryByIndex(hJsonVal, 5, &hJsonValItem));
    168169    RTTEST_CHECK(hTest, RTJsonValueGetType(hJsonValItem) == RTJSONVALTYPE_STRING);
    169     RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueGetStringEx(hJsonValItem, &pszStr));
     170    RTTEST_CHECK_RC_OK_RETV(hTest, RTJsonValueQueryString(hJsonValItem, &pszStr));
    170171    RTTEST_CHECK(hTest, RTJsonValueGetString(hJsonValItem) == pszStr);
    171172    RTTEST_CHECK(hTest, strcmp(pszStr, "6") == 0);
     
    185186        const char *pszName = NULL;
    186187        RTJSONVAL hJsonValMember = NIL_RTJSONVAL;
    187         rc = RTJsonIteratorGetValue(hJsonIt, &hJsonValMember, &pszName);
     188        rc = RTJsonIteratorQueryValue(hJsonIt, &hJsonValMember, &pszName);
    188189        RTTEST_CHECK(hTest, RT_SUCCESS(rc));
    189190        RTTEST_CHECK(hTest, pszName != NULL);
     
    208209                    RTTEST_CHECK(hTest, strcmp(pszName, "string") == 0);
    209210                    const char *pszStr = NULL;
    210                     RTTEST_CHECK_RC_OK(hTest, RTJsonValueGetStringEx(hJsonValMember, &pszStr));
     211                    RTTEST_CHECK_RC_OK(hTest, RTJsonValueQueryString(hJsonValMember, &pszStr));
    211212                    RTTEST_CHECK(hTest, strcmp(pszStr, "test") == 0);
    212213                    break;
     
    216217                    RTTEST_CHECK(hTest, strcmp(pszName, "number") == 0);
    217218                    int64_t i64Num = 0;
    218                     RTTEST_CHECK_RC_OK(hTest, RTJsonValueGetNumber(hJsonValMember, &i64Num));
     219                    RTTEST_CHECK_RC_OK(hTest, RTJsonValueQueryInteger(hJsonValMember, &i64Num));
    219220                    RTTEST_CHECK(hTest, i64Num == 100);
    220221                    break;
     
    237238            RTTEST_CHECK(hTest, rc == VINF_SUCCESS || rc == VERR_JSON_ITERATOR_END);
    238239            if (RT_SUCCESS(rc))
    239                 RTTEST_CHECK_RC_OK(hTest, RTJsonIteratorGetValue(hJsonIt, &hJsonValMember, &pszName));
     240                RTTEST_CHECK_RC_OK(hTest, RTJsonIteratorQueryValue(hJsonIt, &hJsonValMember, &pszName));
    240241        }
    241242        RTJsonIteratorFree(hJsonIt);
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette