rewrite powder.pref handling to use jsoncpp instead of cajun

cajun is a hard to use library with many necessary features missing. It also has been causing the windows version, and probably the mac version, to randomly crash.

Other json stuff still uses cajun (TODO: remove)
This commit is contained in:
jacob1 2016-01-25 01:09:07 -05:00
parent de2f5fe36d
commit 5c1cc0c0fb
7 changed files with 7586 additions and 386 deletions

View File

@ -51,7 +51,7 @@
#include "requestbroker/APIResultParser.h"
#include "cajun/reader.h"
#include "cajun/writer.h"
#include "json/json.h"
extern "C"
{
@ -88,33 +88,30 @@ Client::Client():
configFile.open("powder.pref", std::ios::binary);
if (configFile)
{
int fsize = configFile.tellg();
configFile.seekg(0, std::ios::end);
fsize = configFile.tellg() - (std::streampos)fsize;
configFile.seekg(0, std::ios::beg);
if(fsize)
try
{
try
{
json::Reader::Read(configDocument, configFile);
authUser.ID = ((json::Number)(configDocument["User"]["ID"])).Value();
authUser.SessionID = ((json::String)(configDocument["User"]["SessionID"])).Value();
authUser.SessionKey = ((json::String)(configDocument["User"]["SessionKey"])).Value();
authUser.Username = ((json::String)(configDocument["User"]["Username"])).Value();
preferences.clear();
configFile >> preferences;
int ID = preferences["User"]["ID"].asInt();
std::string Username = preferences["User"]["Username"].asString();
std::string SessionID = preferences["User"]["SessionID"].asString();
std::string SessionKey = preferences["User"]["SessionKey"].asString();
std::string Elevation = preferences["User"]["Elevation"].asString();
std::string userElevation = ((json::String)(configDocument["User"]["Elevation"])).Value();
if(userElevation == "Admin")
authUser.UserElevation = User::ElevationAdmin;
else if(userElevation == "Mod")
authUser.UserElevation = User::ElevationModerator;
else
authUser.UserElevation = User::ElevationNone;
}
catch (json::Exception &e)
{
authUser = User(0, "");
std::cerr << "Error: Could not read data from prefs: " << e.what() << std::endl;
}
authUser.ID = ID;
authUser.Username = Username;
authUser.SessionID = SessionID;
authUser.SessionKey = SessionKey;
if (Elevation == "Admin")
authUser.UserElevation = User::ElevationAdmin;
else if (Elevation == "Mod")
authUser.UserElevation = User::ElevationModerator;
else
authUser.UserElevation = User::ElevationNone;
}
catch (std::exception &e)
{
}
configFile.close();
firstRun = false;
@ -125,7 +122,7 @@ Client::Client():
void Client::Initialise(std::string proxyString)
{
if (GetPrefBool("version.update", false)==true)
if (GetPrefBool("version.update", false))
{
SetPref("version.update", false);
update_finish();
@ -925,22 +922,22 @@ void Client::WritePrefs()
{
if (authUser.ID)
{
configDocument["User"]["ID"] = json::Number(authUser.ID);
configDocument["User"]["SessionID"] = json::String(authUser.SessionID);
configDocument["User"]["SessionKey"] = json::String(authUser.SessionKey);
configDocument["User"]["Username"] = json::String(authUser.Username);
if(authUser.UserElevation == User::ElevationAdmin)
configDocument["User"]["Elevation"] = json::String("Admin");
else if(authUser.UserElevation == User::ElevationModerator)
configDocument["User"]["Elevation"] = json::String("Mod");
preferences["User"]["ID"] = authUser.ID;
preferences["User"]["SessionID"] = authUser.SessionID;
preferences["User"]["SessionKey"] = authUser.SessionKey;
preferences["User"]["Username"] = authUser.Username;
if (authUser.UserElevation == User::ElevationAdmin)
preferences["User"]["Elevation"] = "Admin";
else if (authUser.UserElevation == User::ElevationModerator)
preferences["User"]["Elevation"] = "Mod";
else
configDocument["User"]["Elevation"] = json::String("None");
preferences["User"]["Elevation"] = "None";
}
else
{
configDocument["User"] = json::Null();
preferences["User"] = Json::nullValue;
}
json::Writer::Write(configDocument, configFile);
configFile << preferences;
configFile.close();
}
@ -2018,396 +2015,220 @@ std::list<std::string> * Client::AddTag(int saveID, std::string tag)
return tags;
}
std::vector<std::string> Client::explodePropertyString(std::string property)
{
std::vector<std::string> stringArray;
std::string current = "";
for (std::string::iterator iter = property.begin(); iter != property.end(); ++iter) {
if (*iter == '.') {
if (current.length() > 0) {
stringArray.push_back(current);
current = "";
}
} else {
current += *iter;
}
}
if(current.length() > 0)
stringArray.push_back(current);
return stringArray;
}
// powder.pref preference getting / setting functions
std::string Client::GetPrefString(std::string property, std::string defaultValue)
// Recursively go down the json to get the setting we want
Json::Value Client::GetPref(Json::Value root, std::string prop, Json::Value defaultValue)
{
try
{
json::String value = GetPref(property);
return value.Value();
int dot = prop.find_last_of('.');
if (dot == prop.npos)
return root.get(prop, defaultValue);
else
return GetPref(root[prop.substr(0, dot)], prop.substr(dot+1), defaultValue);
}
catch (json::Exception & e)
catch (std::exception & e)
{
return defaultValue;
}
return defaultValue;
}
double Client::GetPrefNumber(std::string property, double defaultValue)
std::string Client::GetPrefString(std::string prop, std::string defaultValue)
{
try
{
json::Number value = GetPref(property);
return value.Value();
return GetPref(preferences, prop, defaultValue).asString();
}
catch (json::Exception & e)
catch (std::exception & e)
{
return defaultValue;
}
return defaultValue;
}
int Client::GetPrefInteger(std::string property, int defaultValue)
double Client::GetPrefNumber(std::string prop, double defaultValue)
{
try
{
std::stringstream defHexInt;
defHexInt << std::hex << defaultValue;
std::string hexString = GetPrefString(property, defHexInt.str());
int finalValue = defaultValue;
std::stringstream hexInt;
hexInt << hexString;
hexInt >> std::hex >> finalValue;
return finalValue;
return GetPref(preferences, prop, defaultValue).asDouble();
}
catch (json::Exception & e)
catch (std::exception & e)
{
return defaultValue;
}
catch(std::exception & e)
{
}
return defaultValue;
}
unsigned int Client::GetPrefUInteger(std::string property, unsigned int defaultValue)
int Client::GetPrefInteger(std::string prop, int defaultValue)
{
try
{
std::stringstream defHexInt;
defHexInt << std::hex << defaultValue;
std::string hexString = GetPrefString(property, defHexInt.str());
unsigned int finalValue = defaultValue;
std::stringstream hexInt;
hexInt << hexString;
hexInt >> std::hex >> finalValue;
return finalValue;
return GetPref(preferences, prop, defaultValue).asInt();
}
catch (json::Exception & e)
catch (std::exception & e)
{
return defaultValue;
}
catch(std::exception & e)
{
}
return defaultValue;
}
std::vector<std::string> Client::GetPrefStringArray(std::string property)
unsigned int Client::GetPrefUInteger(std::string prop, unsigned int defaultValue)
{
try
{
json::Array value = GetPref(property);
std::vector<std::string> strArray;
for(json::Array::iterator iter = value.Begin(); iter != value.End(); ++iter)
{
try
{
json::String cValue = *iter;
strArray.push_back(cValue.Value());
}
catch (json::Exception & e)
{
}
}
return strArray;
return GetPref(preferences, prop, defaultValue).asUInt();
}
catch (json::Exception & e)
catch (std::exception & e)
{
return defaultValue;
}
}
bool Client::GetPrefBool(std::string prop, bool defaultValue)
{
try
{
return GetPref(preferences, prop, defaultValue).asBool();
}
catch (std::exception & e)
{
return defaultValue;
}
}
std::vector<std::string> Client::GetPrefStringArray(std::string prop)
{
try
{
std::vector<std::string> ret;
Json::Value arr = GetPref(preferences, prop);
for (int i = 0; i < arr.size(); i++)
ret.push_back(arr[i].asString());
return ret;
}
catch (std::exception & e)
{
}
return std::vector<std::string>();
}
std::vector<double> Client::GetPrefNumberArray(std::string property)
std::vector<double> Client::GetPrefNumberArray(std::string prop)
{
try
{
json::Array value = GetPref(property);
std::vector<double> strArray;
for(json::Array::iterator iter = value.Begin(); iter != value.End(); ++iter)
{
try
{
json::Number cValue = *iter;
strArray.push_back(cValue.Value());
}
catch (json::Exception & e)
{
}
}
return strArray;
std::vector<double> ret;
Json::Value arr = GetPref(preferences, prop);
for (int i = 0; i < arr.size(); i++)
ret.push_back(arr[i].asDouble());
return ret;
}
catch (json::Exception & e)
catch (std::exception & e)
{
}
return std::vector<double>();
}
std::vector<int> Client::GetPrefIntegerArray(std::string property)
std::vector<int> Client::GetPrefIntegerArray(std::string prop)
{
try
{
json::Array value = GetPref(property);
std::vector<int> intArray;
for(json::Array::iterator iter = value.Begin(); iter != value.End(); ++iter)
{
try
{
json::String cValue = *iter;
int finalValue = 0;
std::string hexString = cValue.Value();
std::stringstream hexInt;
hexInt << std::hex << hexString;
hexInt >> finalValue;
intArray.push_back(finalValue);
}
catch (json::Exception & e)
{
}
}
return intArray;
std::vector<int> ret;
Json::Value arr = GetPref(preferences, prop);
for (int i = 0; i < arr.size(); i++)
ret.push_back(arr[i].asInt());
return ret;
}
catch (json::Exception & e)
catch (std::exception & e)
{
}
return std::vector<int>();
}
std::vector<unsigned int> Client::GetPrefUIntegerArray(std::string property)
std::vector<unsigned int> Client::GetPrefUIntegerArray(std::string prop)
{
try
{
json::Array value = GetPref(property);
std::vector<unsigned int> intArray;
for(json::Array::iterator iter = value.Begin(); iter != value.End(); ++iter)
{
try
{
json::String cValue = *iter;
unsigned int finalValue = 0;
std::string hexString = cValue.Value();
std::stringstream hexInt;
hexInt << std::hex << hexString;
hexInt >> finalValue;
intArray.push_back(finalValue);
}
catch (json::Exception & e)
{
}
}
return intArray;
std::vector<unsigned int> ret;
Json::Value arr = GetPref(preferences, prop);
for (int i = 0; i < arr.size(); i++)
ret.push_back(arr[i].asUInt());
return ret;
}
catch (json::Exception & e)
catch (std::exception & e)
{
}
return std::vector<unsigned int>();
}
std::vector<bool> Client::GetPrefBoolArray(std::string property)
std::vector<bool> Client::GetPrefBoolArray(std::string prop)
{
try
{
json::Array value = GetPref(property);
std::vector<bool> strArray;
for(json::Array::iterator iter = value.Begin(); iter != value.End(); ++iter)
{
try
{
json::Boolean cValue = *iter;
strArray.push_back(cValue.Value());
}
catch (json::Exception & e)
{
}
}
return strArray;
std::vector<bool> ret;
Json::Value arr = GetPref(preferences, prop);
for (int i = 0; i < arr.size(); i++)
ret.push_back(arr[i].asBool());
return ret;
}
catch (json::Exception & e)
catch (std::exception & e)
{
}
return std::vector<bool>();
}
bool Client::GetPrefBool(std::string property, bool defaultValue)
// Helper preference setting function.
// To actually save any changes to preferences, we need to directly do preferences[property] = thing
// any other way will set the value of a copy of preferences, not the original
// This function will recursively go through and create an object with the property we wanted set,
// and return it to SetPref to do the actual setting
Json::Value Client::SetPrefHelper(Json::Value root, std::string prop, Json::Value value)
{
int dot = prop.find(".");
if (dot == prop.npos)
root[prop] = value;
else
{
Json::Value toSet = GetPref(root, prop.substr(0, dot));
toSet = SetPrefHelper(toSet, prop.substr(dot+1), value);
root[prop.substr(0, dot)] = toSet;
}
return root;
}
void Client::SetPref(std::string prop, Json::Value value)
{
try
{
json::Boolean value = GetPref(property);
return value.Value();
int dot = prop.find(".");
if (dot == prop.npos)
preferences[prop] = value;
else
{
preferences[prop.substr(0, dot)] = SetPrefHelper(preferences[prop.substr(0, dot)], prop.substr(dot+1), value);
}
}
catch (json::Exception & e)
catch (std::exception & e)
{
}
return defaultValue;
}
void Client::SetPref(std::string property, std::string value)
void Client::SetPref(std::string prop, std::vector<Json::Value> value)
{
json::UnknownElement stringValue = json::String(value);
SetPref(property, stringValue);
}
void Client::SetPref(std::string property, double value)
{
json::UnknownElement numberValue = json::Number(value);
SetPref(property, numberValue);
}
void Client::SetPref(std::string property, int value)
{
std::stringstream hexInt;
hexInt << std::hex << value;
json::UnknownElement intValue = json::String(hexInt.str());
SetPref(property, intValue);
}
void Client::SetPref(std::string property, unsigned int value)
{
std::stringstream hexInt;
hexInt << std::hex << value;
json::UnknownElement intValue = json::String(hexInt.str());
SetPref(property, intValue);
}
void Client::SetPref(std::string property, std::vector<std::string> value)
{
json::Array newArray;
for(std::vector<std::string>::iterator iter = value.begin(); iter != value.end(); ++iter)
try
{
newArray.Insert(json::String(*iter));
Json::Value arr;
for (int i = 0; i < value.size(); i++)
{
arr.append(value[i]);
}
SetPref(prop, arr);
}
json::UnknownElement newArrayValue = newArray;
SetPref(property, newArrayValue);
}
void Client::SetPref(std::string property, std::vector<double> value)
{
json::Array newArray;
for(std::vector<double>::iterator iter = value.begin(); iter != value.end(); ++iter)
catch (std::exception & e)
{
newArray.Insert(json::Number(*iter));
}
json::UnknownElement newArrayValue = newArray;
SetPref(property, newArrayValue);
}
void Client::SetPref(std::string property, std::vector<bool> value)
{
json::Array newArray;
for(std::vector<bool>::iterator iter = value.begin(); iter != value.end(); ++iter)
{
newArray.Insert(json::Boolean(*iter));
}
json::UnknownElement newArrayValue = newArray;
SetPref(property, newArrayValue);
}
void Client::SetPref(std::string property, std::vector<int> value)
{
json::Array newArray;
for(std::vector<int>::iterator iter = value.begin(); iter != value.end(); ++iter)
{
std::stringstream hexInt;
hexInt << std::hex << *iter;
newArray.Insert(json::String(hexInt.str()));
}
json::UnknownElement newArrayValue = newArray;
SetPref(property, newArrayValue);
}
void Client::SetPref(std::string property, std::vector<unsigned int> value)
{
json::Array newArray;
for(std::vector<unsigned int>::iterator iter = value.begin(); iter != value.end(); ++iter)
{
std::stringstream hexInt;
hexInt << std::hex << *iter;
newArray.Insert(json::String(hexInt.str()));
}
json::UnknownElement newArrayValue = newArray;
SetPref(property, newArrayValue);
}
void Client::SetPref(std::string property, bool value)
{
json::UnknownElement boolValue = json::Boolean(value);
SetPref(property, boolValue);
}
json::UnknownElement Client::GetPref(std::string property)
{
std::vector<std::string> pTokens = Client::explodePropertyString(property);
const json::UnknownElement & configDocumentCopy = configDocument;
json::UnknownElement currentRef = configDocumentCopy;
for(std::vector<std::string>::iterator iter = pTokens.begin(); iter != pTokens.end(); ++iter)
{
currentRef = ((const json::UnknownElement &)currentRef)[*iter];
}
return currentRef;
}
void Client::setPrefR(std::deque<std::string> tokens, json::UnknownElement & element, json::UnknownElement & value)
{
if(tokens.size())
{
std::string token = tokens.front();
tokens.pop_front();
setPrefR(tokens, element[token], value);
}
else
element = value;
}
void Client::SetPref(std::string property, json::UnknownElement & value)
{
std::vector<std::string> pTokens = Client::explodePropertyString(property);
std::deque<std::string> dTokens(pTokens.begin(), pTokens.end());
std::string token = dTokens.front();
dTokens.pop_front();
setPrefR(dTokens, configDocument[token], value);
}
}

View File

@ -11,7 +11,7 @@
#include "User.h"
#include "UserInfo.h"
#include "cajun/elements.h"
#include "json/json.h"
#include "requestbroker/RequestBroker.h"
@ -76,14 +76,15 @@ private:
int activeThumbRequestTimes[IMGCONNS];
int activeThumbRequestCompleteTimes[IMGCONNS];
std::string activeThumbRequestIDs[IMGCONNS];
static std::vector<std::string> explodePropertyString(std::string property);
void notifyUpdateAvailable();
void notifyAuthUserChanged();
void notifyMessageOfTheDay();
void notifyNewNotification(std::pair<std::string, std::string> notification);
//Config file handle
json::Object configDocument;
// internal preferences handling
Json::Value preferences;
Json::Value GetPref(Json::Value root, std::string prop, Json::Value defaultValue = Json::nullValue);
Json::Value SetPrefHelper(Json::Value root, std::string prop, Json::Value value);
public:
std::vector<ClientListener*> listeners;
@ -171,34 +172,22 @@ public:
bool CheckUpdate(void *updateRequest, bool checkSession);
void Shutdown();
//Force flushing preferences to file on disk.
// preferences functions
void WritePrefs();
std::string GetPrefString(std::string property, std::string defaultValue);
double GetPrefNumber(std::string property, double defaultValue);
int GetPrefInteger(std::string property, int defaultValue);
unsigned int GetPrefUInteger(std::string property, unsigned int defaultValue);
std::vector<std::string> GetPrefStringArray(std::string property);
std::vector<double> GetPrefNumberArray(std::string property);
std::vector<int> GetPrefIntegerArray(std::string property);
std::vector<unsigned int> GetPrefUIntegerArray(std::string property);
std::vector<bool> GetPrefBoolArray(std::string property);
bool GetPrefBool(std::string property, bool defaultValue);
std::string GetPrefString(std::string prop, std::string defaultValue);
double GetPrefNumber(std::string prop, double defaultValue);
int GetPrefInteger(std::string prop, int defaultValue);
unsigned int GetPrefUInteger(std::string prop, unsigned int defaultValue);
bool GetPrefBool(std::string prop, bool defaultValue);
std::vector<std::string> GetPrefStringArray(std::string prop);
std::vector<double> GetPrefNumberArray(std::string prop);
std::vector<int> GetPrefIntegerArray(std::string prop);
std::vector<unsigned int> GetPrefUIntegerArray(std::string prop);
std::vector<bool> GetPrefBoolArray(std::string prop);
void SetPref(std::string property, std::string value);
void SetPref(std::string property, double value);
void SetPref(std::string property, int value);
void SetPref(std::string property, unsigned int value);
void SetPref(std::string property, std::vector<std::string> value);
void SetPref(std::string property, std::vector<double> value);
void SetPref(std::string property, std::vector<int> value);
void SetPref(std::string property, std::vector<unsigned int> value);
void SetPref(std::string property, std::vector<bool> value);
void SetPref(std::string property, bool value);
json::UnknownElement GetPref(std::string property);
void setPrefR(std::deque<std::string> tokens, json::UnknownElement & element, json::UnknownElement & value);
void SetPref(std::string property, json::UnknownElement & value);
void SetPref(std::string prop, Json::Value value);
void SetPref(std::string property, std::vector<Json::Value> value);
};
#endif // CLIENT_H

View File

@ -70,6 +70,6 @@ void ConsoleModel::notifyCurrentCommandChanged()
}
ConsoleModel::~ConsoleModel() {
Client::Ref().SetPref("Console.History", std::vector<std::string>(previousCommands.begin(), previousCommands.end()));
Client::Ref().SetPref("Console.History", std::vector<Json::Value>(previousCommands.begin(), previousCommands.end()));
}

View File

@ -53,31 +53,25 @@ GameModel::GameModel():
ren->SetColourMode(0);
//Load config into renderer
try
ren->SetColourMode(Client::Ref().GetPrefUInteger("Renderer.ColourMode", 0));
tempArray = Client::Ref().GetPrefUIntegerArray("Renderer.DisplayModes");
if(tempArray.size())
{
ren->SetColourMode(Client::Ref().GetPrefUInteger("Renderer.ColourMode", 0));
vector<unsigned int> tempArray = Client::Ref().GetPrefUIntegerArray("Renderer.DisplayModes");
if(tempArray.size())
{
std::vector<unsigned int> displayModes(tempArray.begin(), tempArray.end());
ren->SetDisplayMode(displayModes);
}
tempArray = Client::Ref().GetPrefUIntegerArray("Renderer.RenderModes");
if(tempArray.size())
{
std::vector<unsigned int> renderModes(tempArray.begin(), tempArray.end());
ren->SetRenderMode(renderModes);
}
ren->gravityFieldEnabled = Client::Ref().GetPrefBool("Renderer.GravityField", false);
ren->decorations_enable = Client::Ref().GetPrefBool("Renderer.Decorations", true);
std::vector<unsigned int> displayModes(tempArray.begin(), tempArray.end());
ren->SetDisplayMode(displayModes);
}
catch(json::Exception & e)
tempArray = Client::Ref().GetPrefUIntegerArray("Renderer.RenderModes");
if(tempArray.size())
{
std::vector<unsigned int> renderModes(tempArray.begin(), tempArray.end());
ren->SetRenderMode(renderModes);
}
ren->gravityFieldEnabled = Client::Ref().GetPrefBool("Renderer.GravityField", false);
ren->decorations_enable = Client::Ref().GetPrefBool("Renderer.Decorations", true);
//Load config into simulation
edgeMode = Client::Ref().GetPrefInteger("Simulation.EdgeMode", 0);
sim->SetEdgeMode(edgeMode);
@ -143,10 +137,10 @@ GameModel::~GameModel()
Client::Ref().SetPref("Renderer.ColourMode", ren->GetColourMode());
std::vector<unsigned int> displayModes = ren->GetDisplayMode();
Client::Ref().SetPref("Renderer.DisplayModes", std::vector<unsigned int>(displayModes.begin(), displayModes.end()));
Client::Ref().SetPref("Renderer.DisplayModes", std::vector<Json::Value>(displayModes.begin(), displayModes.end()));
std::vector<unsigned int> renderModes = ren->GetRenderMode();
Client::Ref().SetPref("Renderer.RenderModes", std::vector<unsigned int>(renderModes.begin(), renderModes.end()));
Client::Ref().SetPref("Renderer.RenderModes", std::vector<Json::Value>(renderModes.begin(), renderModes.end()));
Client::Ref().SetPref("Renderer.GravityField", (bool)ren->gravityFieldEnabled);
Client::Ref().SetPref("Renderer.Decorations", (bool)ren->decorations_enable);

255
src/json/json-forwards.h Normal file
View File

@ -0,0 +1,255 @@
/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).
/// It is intended to be used with #include "json/json-forwards.h"
/// This header provides forward declaration for all JsonCpp types.
// //////////////////////////////////////////////////////////////////////
// Beginning of content of file: LICENSE
// //////////////////////////////////////////////////////////////////////
/*
The JsonCpp library's source code, including accompanying documentation,
tests and demonstration applications, are licensed under the following
conditions...
The author (Baptiste Lepilleur) explicitly disclaims copyright in all
jurisdictions which recognize such a disclaimer. In such jurisdictions,
this software is released into the Public Domain.
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
released under the terms of the MIT License (see below).
In jurisdictions which recognize Public Domain property, the user of this
software may choose to accept it either as 1) Public Domain, 2) under the
conditions of the MIT License (see below), or 3) under the terms of dual
Public Domain/MIT License conditions described here, as they choose.
The MIT License is about as close to Public Domain as a license can get, and is
described in clear, concise terms at:
http://en.wikipedia.org/wiki/MIT_License
The full text of the MIT License follows:
========================================================================
Copyright (c) 2007-2010 Baptiste Lepilleur
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
========================================================================
(END LICENSE TEXT)
The MIT license is compatible with both the GPL and commercial
software, affording one all of the rights of Public Domain with the
minor nuisance of being required to keep the above copyright notice
and license text in the source code. Note also that by accepting the
Public Domain "license" you can re-license your copy using whatever
license you like.
*/
// //////////////////////////////////////////////////////////////////////
// End of content of file: LICENSE
// //////////////////////////////////////////////////////////////////////
#ifndef JSON_FORWARD_AMALGATED_H_INCLUDED
# define JSON_FORWARD_AMALGATED_H_INCLUDED
/// If defined, indicates that the source file is amalgated
/// to prevent private header inclusion.
#define JSON_IS_AMALGAMATION
// //////////////////////////////////////////////////////////////////////
// Beginning of content of file: include/json/config.h
// //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef JSON_CONFIG_H_INCLUDED
#define JSON_CONFIG_H_INCLUDED
/// If defined, indicates that json library is embedded in CppTL library.
//# define JSON_IN_CPPTL 1
/// If defined, indicates that json may leverage CppTL library
//# define JSON_USE_CPPTL 1
/// If defined, indicates that cpptl vector based map should be used instead of
/// std::map
/// as Value container.
//# define JSON_USE_CPPTL_SMALLMAP 1
// If non-zero, the library uses exceptions to report bad input instead of C
// assertion macros. The default is to use exceptions.
#ifndef JSON_USE_EXCEPTION
#define JSON_USE_EXCEPTION 1
#endif
/// If defined, indicates that the source file is amalgated
/// to prevent private header inclusion.
/// Remarks: it is automatically defined in the generated amalgated header.
// #define JSON_IS_AMALGAMATION
#ifdef JSON_IN_CPPTL
#include <cpptl/config.h>
#ifndef JSON_USE_CPPTL
#define JSON_USE_CPPTL 1
#endif
#endif
#ifdef JSON_IN_CPPTL
#define JSON_API CPPTL_API
#elif defined(JSON_DLL_BUILD)
#if defined(_MSC_VER)
#define JSON_API __declspec(dllexport)
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
#endif // if defined(_MSC_VER)
#elif defined(JSON_DLL)
#if defined(_MSC_VER)
#define JSON_API __declspec(dllimport)
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
#endif // if defined(_MSC_VER)
#endif // ifdef JSON_IN_CPPTL
#if !defined(JSON_API)
#define JSON_API
#endif
// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
// integer
// Storages, and 64 bits integer support is disabled.
// #define JSON_NO_INT64 1
#if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6
// Microsoft Visual Studio 6 only support conversion from __int64 to double
// (no conversion from unsigned __int64).
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
// characters in the debug information)
// All projects I've ever seen with VS6 were using this globally (not bothering
// with pragma push/pop).
#pragma warning(disable : 4786)
#endif // if defined(_MSC_VER) && _MSC_VER < 1200 // MSVC 6
#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008
/// Indicates that the following function is deprecated.
#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
#elif defined(__clang__) && defined(__has_feature)
#if __has_feature(attribute_deprecated_with_message)
#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
#endif
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
#elif defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
#endif
#if !defined(JSONCPP_DEPRECATED)
#define JSONCPP_DEPRECATED(message)
#endif // if !defined(JSONCPP_DEPRECATED)
namespace Json {
typedef int Int;
typedef unsigned int UInt;
#if defined(JSON_NO_INT64)
typedef int LargestInt;
typedef unsigned int LargestUInt;
#undef JSON_HAS_INT64
#else // if defined(JSON_NO_INT64)
// For Microsoft Visual use specific types as long long is not supported
#if defined(_MSC_VER) // Microsoft Visual Studio
typedef __int64 Int64;
typedef unsigned __int64 UInt64;
#else // if defined(_MSC_VER) // Other platforms, use long long
typedef long long int Int64;
typedef unsigned long long int UInt64;
#endif // if defined(_MSC_VER)
typedef Int64 LargestInt;
typedef UInt64 LargestUInt;
#define JSON_HAS_INT64
#endif // if defined(JSON_NO_INT64)
} // end namespace Json
#endif // JSON_CONFIG_H_INCLUDED
// //////////////////////////////////////////////////////////////////////
// End of content of file: include/json/config.h
// //////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////
// Beginning of content of file: include/json/forwards.h
// //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef JSON_FORWARDS_H_INCLUDED
#define JSON_FORWARDS_H_INCLUDED
#if !defined(JSON_IS_AMALGAMATION)
#include "config.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
namespace Json {
// writer.h
class FastWriter;
class StyledWriter;
// reader.h
class Reader;
// features.h
class Features;
// value.h
typedef unsigned int ArrayIndex;
class StaticString;
class Path;
class PathArgument;
class Value;
class ValueIteratorBase;
class ValueIterator;
class ValueConstIterator;
} // namespace Json
#endif // JSON_FORWARDS_H_INCLUDED
// //////////////////////////////////////////////////////////////////////
// End of content of file: include/json/forwards.h
// //////////////////////////////////////////////////////////////////////
#endif //ifndef JSON_FORWARD_AMALGATED_H_INCLUDED

2017
src/json/json.h Normal file

File diff suppressed because it is too large Load Diff

5124
src/json/jsoncpp.cpp Normal file

File diff suppressed because it is too large Load Diff