BJson: Use the normal "input, output" argument ordering instead of the reverse.
Update all in-tree consumers of the BJson API to match. Also added const-qualifiers to the BString versions of the API, and added the leading "_" to the header guards.
This commit is contained in:
parent
56c500389f
commit
6c9415e3ca
@ -2,8 +2,8 @@
|
||||
* Copyright 2014, Augustin Cavalier (waddlesplash)
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef JSON_H
|
||||
#define JSON_H
|
||||
#ifndef _JSON_H
|
||||
#define _JSON_H
|
||||
|
||||
#include <Message.h>
|
||||
#include <String.h>
|
||||
@ -18,14 +18,14 @@ public:
|
||||
};
|
||||
|
||||
public:
|
||||
static status_t Parse(BMessage& message, const char* JSON);
|
||||
static status_t Parse(BMessage& message, BString& JSON);
|
||||
static status_t Parse(const char* JSON, BMessage& message);
|
||||
static status_t Parse(const BString& JSON, BMessage& message);
|
||||
|
||||
private:
|
||||
static void _Parse(BMessage& message, BString& JSON);
|
||||
static BString _ParseString(BString& JSON, int32& pos);
|
||||
static double _ParseNumber(BString& JSON, int32& pos);
|
||||
static bool _ParseConstant(BString& JSON, int32& pos,
|
||||
static void _Parse(const BString& JSON, BMessage& message);
|
||||
static BString _ParseString(const BString& JSON, int32& pos);
|
||||
static double _ParseNumber(const BString& JSON, int32& pos);
|
||||
static bool _ParseConstant(const BString& JSON, int32& pos,
|
||||
const char* constant);
|
||||
};
|
||||
|
||||
@ -33,4 +33,4 @@ private:
|
||||
|
||||
using BPrivate::BJson;
|
||||
|
||||
#endif // JSON_H
|
||||
#endif // _JSON_H
|
||||
|
@ -252,9 +252,8 @@ status_t
|
||||
ServerIconExportUpdateProcess::_PopulateIconMetaData(IconMetaData& iconMetaData,
|
||||
BString& jsonString) const
|
||||
{
|
||||
BJson parser;
|
||||
BMessage infoMetaDataMessage;
|
||||
status_t result = parser.Parse(infoMetaDataMessage, jsonString);
|
||||
status_t result = BJson::Parse(jsonString, infoMetaDataMessage);
|
||||
|
||||
if (result == B_OK)
|
||||
return _PopulateIconMetaData(iconMetaData, infoMetaDataMessage);
|
||||
|
@ -679,8 +679,7 @@ WebAppInterface::_SendJsonRequest(const char* domain, BString jsonString,
|
||||
if (jsonString.Length() == 0)
|
||||
return B_ERROR;
|
||||
|
||||
BJson parser;
|
||||
status_t status = parser.Parse(reply, jsonString);
|
||||
status_t status = BJson::Parse(jsonString, reply);
|
||||
if (ServerSettings::UrlConnectionTraceLoggingEnabled() &&
|
||||
status == B_BAD_DATA) {
|
||||
printf("Parser choked on JSON:\n%s\n", jsonString.String());
|
||||
|
@ -118,7 +118,7 @@ BGeolocation::LocateSelf(float& latitude, float& longitude)
|
||||
}
|
||||
|
||||
BMessage data;
|
||||
result = BJson::Parse(data, (char*)listener.result.Buffer());
|
||||
result = BJson::Parse((char*)listener.result.Buffer(), data);
|
||||
delete http;
|
||||
if (result != B_OK) {
|
||||
return result;
|
||||
|
@ -60,18 +60,18 @@ private:
|
||||
|
||||
|
||||
status_t
|
||||
BJson::Parse(BMessage& message, const char* JSON)
|
||||
BJson::Parse(const char* JSON, BMessage& message)
|
||||
{
|
||||
BString temp(JSON);
|
||||
return Parse(message, temp);
|
||||
return Parse(temp, message);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BJson::Parse(BMessage& message, BString& JSON)
|
||||
BJson::Parse(const BString& JSON, BMessage& message)
|
||||
{
|
||||
try {
|
||||
_Parse(message, JSON);
|
||||
_Parse(JSON, message);
|
||||
return B_OK;
|
||||
} catch (ParseException e) {
|
||||
e.PrintToStream();
|
||||
@ -85,7 +85,7 @@ BJson::Parse(BMessage& message, BString& JSON)
|
||||
|
||||
|
||||
void
|
||||
BJson::_Parse(BMessage& message, BString& JSON)
|
||||
BJson::_Parse(const BString& JSON, BMessage& message)
|
||||
{
|
||||
BMessageBuilder builder(message);
|
||||
int32 pos = 0;
|
||||
@ -315,7 +315,7 @@ BJson::_Parse(BMessage& message, BString& JSON)
|
||||
|
||||
|
||||
BString
|
||||
BJson::_ParseString(BString& JSON, int32& pos)
|
||||
BJson::_ParseString(const BString& JSON, int32& pos)
|
||||
{
|
||||
if (JSON[pos] != '"') // Verify we're at the start of a string.
|
||||
return BString("");
|
||||
@ -379,7 +379,7 @@ BJson::_ParseString(BString& JSON, int32& pos)
|
||||
|
||||
|
||||
double
|
||||
BJson::_ParseNumber(BString& JSON, int32& pos)
|
||||
BJson::_ParseNumber(const BString& JSON, int32& pos)
|
||||
{
|
||||
BString value;
|
||||
bool isDouble = false;
|
||||
@ -429,7 +429,7 @@ BJson::_ParseNumber(BString& JSON, int32& pos)
|
||||
|
||||
|
||||
bool
|
||||
BJson::_ParseConstant(BString& JSON, int32& pos, const char* constant)
|
||||
BJson::_ParseConstant(const BString& JSON, int32& pos, const char* constant)
|
||||
{
|
||||
BString value;
|
||||
JSON.CopyInto(value, pos, strlen(constant));
|
||||
|
Loading…
Reference in New Issue
Block a user