VirtualBox

Changeset 62021 in vbox


Ignore:
Timestamp:
Jul 5, 2016 9:34:17 AM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
108482
Message:

Runtime/RTJson: Fix review todos

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/json.h

    r61995 r62021  
    154154 * @param   hJsonVal        The JSON value handle.
    155155 * @param   ppszStr         Where to store the pointer to the string on success.
    156  * @todo r=bird: Rename to RTJsonValueQueryString as getters returns values
    157  *               not status codes (see guidelines).
    158  */
    159 RTDECL(int) RTJsonValueGetStringEx(RTJSONVAL hJsonVal, const char **ppszStr);
     156 */
     157RTDECL(int) RTJsonValueQueryString(RTJSONVAL hJsonVal, const char **ppszStr);
    160158
    161159/**
     
    170168 *          numbers currently.  When it does, it will be in the form of a
    171169 *          RTJsonValueQueryFloat method.
    172  *
    173  * @todo r=bird: Rename to RTJsonValueQueryInteger as getters returns values
    174  *               not status codes (see guidelines), and "Integer" is better for
    175  *               future floating point support.
    176  */
    177 RTDECL(int) RTJsonValueGetNumber(RTJSONVAL hJsonVal, int64_t *pi64Num);
     170 */
     171RTDECL(int) RTJsonValueQueryInteger(RTJSONVAL hJsonVal, int64_t *pi64Num);
    178172
    179173/**
     
    186180 * @param   pszName         The member name of the object.
    187181 * @param   phJsonVal       Where to store the handle to the JSON value on success.
    188  * @todo r=bird: Rename to RTJsonValueQueryByName as getters returns
    189  *               values not status codes (see guidelines).
    190  */
    191 RTDECL(int) RTJsonValueGetByName(RTJSONVAL hJsonVal, const char *pszName, PRTJSONVAL phJsonVal);
     182 */
     183RTDECL(int) RTJsonValueQueryByName(RTJSONVAL hJsonVal, const char *pszName, PRTJSONVAL phJsonVal);
    192184
    193185/**
     
    201193 * @param   pszName         The member name of the object.
    202194 * @param   pi64Num         Where to store the number on success.
    203  * @todo r=bird: Rename to RTJsonValueQueryNumberByName as getters returns
    204  *               values not status codes (see guidelines).
    205  */
    206 RTDECL(int) RTJsonValueGetNumberByName(RTJSONVAL hJsonVal, const char *pszName, int64_t *pi64Num);
     195 */
     196RTDECL(int) RTJsonValueQueryIntegerByName(RTJSONVAL hJsonVal, const char *pszName, int64_t *pi64Num);
    207197
    208198/**
     
    217207 * @param   ppszStr         Where to store the pointer to the string on success.
    218208 *                          Must be freed with RTStrFree().
    219  * @todo r=bird: Rename to RTJsonValueQueryStringByName as getters returns
    220  *               values not status codes (see guidelines).
    221  */
    222 RTDECL(int) RTJsonValueGetStringByName(RTJSONVAL hJsonVal, const char *pszName, char **ppszStr);
     209 */
     210RTDECL(int) RTJsonValueQueryStringByName(RTJSONVAL hJsonVal, const char *pszName, char **ppszStr);
    223211
    224212/**
     
    232220 * @param   pszName         The member name of the object.
    233221 * @param   pfBoolean       Where to store the boolean value on success.
    234  * @todo r=bird: Rename to RTJsonValueQueryBooleanByName as getters returns
    235  *               values not status codes (see guidelines).
    236  */
    237 RTDECL(int) RTJsonValueGetBooleanByName(RTJSONVAL hJsonVal, const char *pszName, bool *pfBoolean);
     222 */
     223RTDECL(int) RTJsonValueQueryBooleanByName(RTJSONVAL hJsonVal, const char *pszName, bool *pfBoolean);
    238224
    239225/**
     
    253239 * @param   hJsonVal        The JSON value handle.
    254240 * @param   pcItems         Where to store the size of the JSON array value on success.
    255  * @todo r=bird: Rename to RTJsonValueQueryArraySize as getters returns
    256  *               values not status codes (see guidelines).
    257  *               Implementation is using 'uint32_t' not 'unsigned', goes for the
    258  *               other functions here.
    259  */
    260 RTDECL(int) RTJsonValueGetArraySizeEx(RTJSONVAL hJsonVal, unsigned *pcItems);
     241 */
     242RTDECL(int) RTJsonValueQueryArraySize(RTJSONVAL hJsonVal, unsigned *pcItems);
    261243
    262244/**
     
    270252 * @param   idx             The index to get the value from.
    271253 * @param   phJsonVal       Where to store the handle to the JSON value on success.
    272  * @todo r=bird: Rename to RTJsonValueQueryByIndex as getters returns
    273  *               values not status codes (see guidelines).
    274  */
    275 RTDECL(int) RTJsonValueGetByIndex(RTJSONVAL hJsonVal, unsigned idx, PRTJSONVAL phJsonVal);
     254 */
     255RTDECL(int) RTJsonValueQueryByIndex(RTJSONVAL hJsonVal, unsigned idx, PRTJSONVAL phJsonVal);
    276256
    277257/**
     
    294274 * @param   ppszName        Where to store the object member name for an object.
    295275 *                          NULL is returned for arrays.
    296  * @todo r=bird: Rename to RTJsonIteratorQueryValue as getters returns
    297  *               values not status codes (see guidelines).
    298  */
    299 RTDECL(int) RTJsonIteratorGetValue(RTJSONIT hJsonIt, PRTJSONVAL phJsonVal, const char **ppszName);
     276 */
     277RTDECL(int) RTJsonIteratorQueryValue(RTJSONIT hJsonIt, PRTJSONVAL phJsonVal, const char **ppszName);
    300278
    301279/**
  • trunk/include/iprt/mangling.h

    r61737 r62021  
    955955# define RTJsonIteratorBegin                            RT_MANGLER(RTJsonIteratorBegin)
    956956# define RTJsonIteratorFree                             RT_MANGLER(RTJsonIteratorFree)
    957 # define RTJsonIteratorGetValue                         RT_MANGLER(RTJsonIteratorGetValue)
    958957# define RTJsonIteratorNext                             RT_MANGLER(RTJsonIteratorNext)
     958# define RTJsonIteratorQueryValue                       RT_MANGLER(RTJsonIteratorQueryValue)
    959959# define RTJsonParseFromBuf                             RT_MANGLER(RTJsonParseFromBuf)
    960960# define RTJsonParseFromFile                            RT_MANGLER(RTJsonParseFromFile)
    961961# define RTJsonParseFromString                          RT_MANGLER(RTJsonParseFromString)
    962962# define RTJsonValueGetArraySize                        RT_MANGLER(RTJsonValueGetArraySize)
    963 # define RTJsonValueGetArraySizeEx                      RT_MANGLER(RTJsonValueGetArraySizeEx)
    964 # define RTJsonValueGetBooleanByName                    RT_MANGLER(RTJsonValueGetBooleanByName)
    965 # define RTJsonValueGetByIndex                          RT_MANGLER(RTJsonValueGetByIndex)
    966 # define RTJsonValueGetByName                           RT_MANGLER(RTJsonValueGetByName)
    967 # define RTJsonValueGetNumber                           RT_MANGLER(RTJsonValueGetNumber)
    968 # define RTJsonValueGetNumberByName                     RT_MANGLER(RTJsonValueGetNumberByName)
    969963# define RTJsonValueGetString                           RT_MANGLER(RTJsonValueGetString)
    970 # define RTJsonValueGetStringByName                     RT_MANGLER(RTJsonValueGetStringByName)
    971 # define RTJsonValueGetStringEx                         RT_MANGLER(RTJsonValueGetStringEx)
    972964# define RTJsonValueGetType                             RT_MANGLER(RTJsonValueGetType)
     965# define RTJsonValueQueryArraySizeEx                    RT_MANGLER(RTJsonValueQueryArraySize)
     966# define RTJsonValueQueryBooleanByName                  RT_MANGLER(RTJsonValueQueryBooleanByName)
     967# define RTJsonValueQueryByIndex                        RT_MANGLER(RTJsonValueQueryByIndex)
     968# define RTJsonValueQueryByName                         RT_MANGLER(RTJsonValueQueryByName)
     969# define RTJsonValueQueryInteger                        RT_MANGLER(RTJsonValueQueryInteger)
     970# define RTJsonValueQueryIntegerByName                  RT_MANGLER(RTJsonValueQueryIntegerByName)
     971# define RTJsonValueQueryString                         RT_MANGLER(RTJsonValueQueryString)
     972# define RTJsonValueQueryStringByName                   RT_MANGLER(RTJsonValueQueryStringByName)
    973973# define RTJsonValueRelease                             RT_MANGLER(RTJsonValueRelease)
    974974# define RTJsonValueRetain                              RT_MANGLER(RTJsonValueRetain)
  • 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);
Note: See TracChangeset for help on using the changeset viewer.

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