hrev50944 adds 1 changeset to branch 'master'
old head: 56c500389f2c9f1ba6f8aee1a7af3437059db6fc
new head: 6c9415e3caa929ac2ae6126474c08e0b2b3cb358
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=6c9415e3caa9+%5E56c500389f2c
----------------------------------------------------------------------------
6c9415e3caa9: 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.
[ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev50944
Commit: 6c9415e3caa929ac2ae6126474c08e0b2b3cb358
URL: http://cgit.haiku-os.org/haiku/commit/?id=6c9415e3caa9
Author: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date: Thu Feb 9 18:12:49 2017 UTC
----------------------------------------------------------------------------
5 files changed, 20 insertions(+), 22 deletions(-)
headers/private/shared/Json.h | 18 +++++++++---------
.../server/ServerIconExportUpdateProcess.cpp | 3 +--
src/apps/haikudepot/server/WebAppInterface.cpp | 3 +--
src/kits/shared/Geolocation.cpp | 2 +-
src/kits/shared/Json.cpp | 16 ++++++++--------
----------------------------------------------------------------------------
diff --git a/headers/private/shared/Json.h b/headers/private/shared/Json.h
index 6df2648..edb8e45 100644
--- a/headers/private/shared/Json.h
+++ b/headers/private/shared/Json.h
@@ -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
diff --git a/src/apps/haikudepot/server/ServerIconExportUpdateProcess.cpp
b/src/apps/haikudepot/server/ServerIconExportUpdateProcess.cpp
index 932da9b..c7d8de1 100644
--- a/src/apps/haikudepot/server/ServerIconExportUpdateProcess.cpp
+++ b/src/apps/haikudepot/server/ServerIconExportUpdateProcess.cpp
@@ -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);
diff --git a/src/apps/haikudepot/server/WebAppInterface.cpp
b/src/apps/haikudepot/server/WebAppInterface.cpp
index 4036a64..6ca4efa 100644
--- a/src/apps/haikudepot/server/WebAppInterface.cpp
+++ b/src/apps/haikudepot/server/WebAppInterface.cpp
@@ -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());
diff --git a/src/kits/shared/Geolocation.cpp b/src/kits/shared/Geolocation.cpp
index 7d2f4e8..db712fb 100644
--- a/src/kits/shared/Geolocation.cpp
+++ b/src/kits/shared/Geolocation.cpp
@@ -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;
diff --git a/src/kits/shared/Json.cpp b/src/kits/shared/Json.cpp
index 739b37de..057f25d 100644
--- a/src/kits/shared/Json.cpp
+++ b/src/kits/shared/Json.cpp
@@ -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));