Changeset 83425 in vbox
- Timestamp:
- Mar 25, 2020 7:37:25 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/json.h
r82968 r83425 125 125 126 126 /** 127 * Parses a JSON document from the given VFS file 128 * returning the root JSON value. 129 * 130 * @returns IPRT status code. 131 * @retval VERR_JSON_MALFORMED if the document does not conform to the spec. 132 * @param phJsonVal Where to store the handle to the JSON value on success. 133 * @param hVfsFile The VFS file to parse. 134 * @param pErrInfo Where to store extended error info. Optional. 135 */ 136 RTDECL(int) RTJsonParseFromVfsFile(PRTJSONVAL phJsonVal, RTVFSFILE hVfsFile, PRTERRINFO pErrInfo); 137 138 /** 127 139 * Retain a given JSON value. 128 140 * -
trunk/include/iprt/mangling.h
r83369 r83425 1171 1171 # define RTJsonParseFromFile RT_MANGLER(RTJsonParseFromFile) 1172 1172 # define RTJsonParseFromString RT_MANGLER(RTJsonParseFromString) 1173 # define RTJsonParseFromVfsFile RT_MANGLER(RTJsonParseFromVfsFile) 1173 1174 # define RTJsonValueGetArraySize RT_MANGLER(RTJsonValueGetArraySize) 1174 1175 # define RTJsonValueGetString RT_MANGLER(RTJsonValueGetString) -
trunk/src/VBox/Runtime/common/misc/json.cpp
r82968 r83425 40 40 #include <iprt/string.h> 41 41 #include <iprt/utf16.h> 42 #include <iprt/vfs.h> 42 43 43 44 #include <stdlib.h> /* strtod() */ … … 260 261 PRTSTREAM hStream; 261 262 const uint8_t *pbBuf; 263 RTVFSFILE hVfsFile; 262 264 } u; 263 265 } RTJSONREADERARGS; … … 1429 1431 } 1430 1432 1433 /** 1434 * Read callback for RTJsonParseFromVfsFile(). 1435 */ 1436 static DECLCALLBACK(int) rtJsonTokenizerParseFromVfsFile(void *pvUser, size_t offInput, 1437 void *pvBuf, size_t cbBuf, 1438 size_t *pcbRead) 1439 { 1440 PRTJSONREADERARGS pArgs = (PRTJSONREADERARGS)pvUser; 1441 1442 RT_NOREF_PV(offInput); 1443 1444 size_t cbRead = 0; 1445 int rc = RTVfsFileRead(pArgs->u.hVfsFile, pvBuf, cbBuf, &cbRead); 1446 if (RT_SUCCESS(rc)) 1447 *pcbRead = cbRead; 1448 1449 return rc; 1450 } 1451 1431 1452 RTDECL(int) RTJsonParseFromBuf(PRTJSONVAL phJsonVal, const uint8_t *pbBuf, size_t cbBuf, PRTERRINFO pErrInfo) 1432 1453 { … … 1491 1512 } 1492 1513 RTStrmClose(Args.u.hStream); 1514 } 1515 1516 return rc; 1517 } 1518 1519 RTDECL(int) RTJsonParseFromVfsFile(PRTJSONVAL phJsonVal, RTVFSFILE hVfsFile, PRTERRINFO pErrInfo) 1520 { 1521 AssertPtrReturn(phJsonVal, VERR_INVALID_POINTER); 1522 AssertReturn(hVfsFile != NIL_RTVFSFILE, VERR_INVALID_POINTER); 1523 1524 int rc = VINF_SUCCESS; 1525 RTJSONREADERARGS Args; 1526 RTJSONTOKENIZER Tokenizer; 1527 1528 Args.cbData = 0; 1529 Args.u.hVfsFile = hVfsFile; 1530 rc = rtJsonTokenizerInit(&Tokenizer, rtJsonTokenizerParseFromVfsFile, &Args, pErrInfo); 1531 if (RT_SUCCESS(rc)) 1532 { 1533 rc = rtJsonParse(&Tokenizer, phJsonVal); 1534 rtJsonTokenizerDestroy(&Tokenizer); 1493 1535 } 1494 1536
Note:
See TracChangeset
for help on using the changeset viewer.