Messy commit. Testing suff and some improvements to how data is shown.
This commit is contained in:
parent
bebb3391c3
commit
3a13b7ffb4
59 changed files with 2045 additions and 716 deletions
409
core/ExplainTreeModelItem.cpp
Normal file
409
core/ExplainTreeModelItem.cpp
Normal file
|
|
@ -0,0 +1,409 @@
|
|||
#include "ExplainTreeModelItem.h"
|
||||
#include "json/json.h"
|
||||
#include <limits>
|
||||
|
||||
namespace {
|
||||
|
||||
ExplainTreeModelItemPtr createPlanItemFromJson(Json::Value &plan)
|
||||
{
|
||||
|
||||
const auto json_null = Json::Value::nullSingleton();
|
||||
ExplainTreeModelItemPtr result = std::make_shared<ExplainTreeModelItem>();
|
||||
result->nodeType = QString::fromStdString(plan.get("Node Type", json_null).asString());
|
||||
result->parallelAware = plan.get("Parallel Aware", json_null).asBool();
|
||||
result->strategy = QString::fromStdString(plan.get("Strategy", json_null).asString());
|
||||
result->joinType = QString::fromStdString(plan.get("Join Type", json_null).asString());
|
||||
result->startupCost = plan.get("Startup Cost", json_null).asFloat();
|
||||
result->totalCost = plan.get("Total Cost", json_null).asFloat();
|
||||
result->estimatedRows = plan.get("Plan Rows", json_null).asInt();
|
||||
result->planWidth = plan.get("Plan Width", json_null).asInt();
|
||||
result->actualStartupTime = plan.get("Actual Startup Time", json_null).asFloat();
|
||||
result->actualTotalTime = plan.get("Actual Total Time", json_null).asFloat();
|
||||
result->actualRows = plan.get("Actual Rows", json_null).asInt();
|
||||
result->actualLoops = plan.get("Actual Loops", json_null).asInt();
|
||||
|
||||
result->relationName = QString::fromStdString(plan.get("Relation Name", json_null).asString());
|
||||
result->alias = QString::fromStdString(plan.get("Alias", json_null).asString());
|
||||
result->scanDirection = QString::fromStdString(plan.get("Scan Direction", json_null).asString());
|
||||
result->indexName = QString::fromStdString(plan.get("Index Name", json_null).asString());
|
||||
result->indexCondition = QString::fromStdString(plan.get("Index Cond", json_null).asString());
|
||||
result->indexRecheck = QString::fromStdString(plan.get("Rows Removed by Index Recheck", json_null).asString());
|
||||
result->filter = QString::fromStdString(plan.get("Filter", json_null).asString());
|
||||
result->hashCondition = QString::fromStdString(plan.get("Hash Cond", json_null).asString());
|
||||
|
||||
result->sortKey = QString::fromStdString(plan.get("Sort Key", json_null).toStyledString());
|
||||
result->sortMethod = QString::fromStdString(plan.get("Sort Method", json_null).asString());
|
||||
|
||||
result->sortSpaceUsed = plan.get("Sort Space Used", json_null).asInt();
|
||||
result->sortSpaceType = QString::fromStdString(plan.get("Sort Space Type", json_null).asString());
|
||||
|
||||
result->sharedBlocks.hit = plan.get("Shared Hit Blocks", json_null).asInt();
|
||||
result->sharedBlocks.read = plan.get("Shared Read Blocks", json_null).asInt();
|
||||
result->sharedBlocks.dirtied = plan.get("Shared Dirtied Blocks", json_null).asInt();
|
||||
result->sharedBlocks.written = plan.get("Shared Written Blocks", json_null).asInt();
|
||||
|
||||
result->localBlocks.hit = plan.get("Local Hit Blocks", json_null).asInt();
|
||||
result->localBlocks.read = plan.get("Local Read Blocks", json_null).asInt();
|
||||
result->localBlocks.dirtied = plan.get("Local Dirtied Blocks", json_null).asInt();
|
||||
result->localBlocks.written = plan.get("Local Written Blocks", json_null).asInt();
|
||||
|
||||
result->tempBlocks.read = plan.get("Temp Read Blocks", json_null).asInt();
|
||||
result->tempBlocks.written = plan.get("Temp Written Blocks", json_null).asInt();
|
||||
result->ioTimes.read = plan.get("I/O Read Time", json_null).asDouble();
|
||||
result->ioTimes.write = plan.get("I/O Write Time", json_null).asDouble();
|
||||
|
||||
Json::Value &plans = plan["Plans"];
|
||||
if (plans.isArray()) {
|
||||
for (auto p : plans) {
|
||||
result->appendChild(
|
||||
createPlanItemFromJson(p));
|
||||
}
|
||||
}
|
||||
|
||||
// "Parallel Aware": false,
|
||||
return result;
|
||||
}
|
||||
|
||||
} // END of unnamed namespace
|
||||
|
||||
ExplainRoot::SPtr ExplainRoot::createFromJson(Json::Value &json)
|
||||
{
|
||||
auto res = std::make_shared<ExplainRoot>();
|
||||
// Explain always seems to be an array with one element
|
||||
if (json.isArray()) {
|
||||
if (json.size() > 0) {
|
||||
Json::Value &explain = json[0];
|
||||
|
||||
Json::Value &plan = explain["Plan"];
|
||||
res->plan = createPlanItemFromJson(plan);
|
||||
|
||||
res->planningTime = explain["Planning Time"].asFloat();
|
||||
res->executionTime = explain["Execution Time"].asFloat();
|
||||
res->totalRuntime = explain["Total Runtime"].asFloat();
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
ExplainTreeModelItem::ExplainTreeModelItem() = default;
|
||||
|
||||
ExplainTreeModelItem::~ExplainTreeModelItem() = default;
|
||||
|
||||
void ExplainTreeModelItem::appendChild(ItemPtr child)
|
||||
{
|
||||
child->setParent(shared_from_this());
|
||||
m_childItems.push_back(child);
|
||||
}
|
||||
|
||||
ExplainTreeModelItemPtr ExplainTreeModelItem::child(int row)
|
||||
{
|
||||
return m_childItems.at(row);
|
||||
}
|
||||
|
||||
int ExplainTreeModelItem::childCount() const
|
||||
{
|
||||
return m_childItems.size();
|
||||
}
|
||||
|
||||
//int ExplainTreeModelItem::columnCount() const
|
||||
//{
|
||||
// return 6;
|
||||
//}
|
||||
|
||||
//QVariant ExplainTreeModelItem::data(int column) const
|
||||
//{
|
||||
// QVariant r;
|
||||
// if (column == 0) {
|
||||
// r = nodeType;
|
||||
// }
|
||||
// else if (column == 1) {
|
||||
|
||||
// }
|
||||
// return r;
|
||||
//}
|
||||
|
||||
int ExplainTreeModelItem::row() const
|
||||
{
|
||||
int idx = 0;
|
||||
auto p = m_parentItem.lock();
|
||||
if (p) {
|
||||
idx = std::find(p->m_childItems.begin(), p->m_childItems.end(), shared_from_this()) - p->m_childItems.begin();
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
void ExplainTreeModelItem::setParent(ItemPtr parent)
|
||||
{
|
||||
m_parentItem = parent;
|
||||
}
|
||||
|
||||
ExplainTreeModelItemPtr ExplainTreeModelItem::parent()
|
||||
{
|
||||
auto p = m_parentItem.lock();
|
||||
return p;
|
||||
}
|
||||
|
||||
//void ExplainTreeModelItem::setNodeType(QString nt)
|
||||
//{
|
||||
// m_nodeType = std::move(nt);
|
||||
//}
|
||||
|
||||
//const QString& ExplainTreeModelItem::nodeType() const
|
||||
//{
|
||||
// return m_nodeType;
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setParallelAware(bool aware)
|
||||
//{
|
||||
// m_parallelAware = aware;
|
||||
//}
|
||||
|
||||
//bool ExplainTreeModelItem::getParallelAware() const
|
||||
//{
|
||||
// return m_parallelAware;
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setStrategy(QString strat)
|
||||
//{
|
||||
// m_strategy = std::move(strat);
|
||||
//}
|
||||
|
||||
//const QString& ExplainTreeModelItem::strategy() const
|
||||
//{
|
||||
// return m_strategy;
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setJoinType(QString jointype)
|
||||
//{
|
||||
// m_joinType = jointype;
|
||||
//}
|
||||
|
||||
//QString ExplainTreeModelItem::joinType() const
|
||||
//{
|
||||
// return m_joinType;
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setStartupCost(float cost)
|
||||
//{
|
||||
// m_startupCost = cost;
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setTotalCost(float cost)
|
||||
//{
|
||||
// m_totalCost = cost;
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setEstimatedRows(long long estimated)
|
||||
//{
|
||||
// m_estimatedRows = estimated;
|
||||
//}
|
||||
|
||||
//long long ExplainTreeModelItem::estimatedRows() const
|
||||
//{
|
||||
// return m_estimatedRows;
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setPlanWidth(int width)
|
||||
//{
|
||||
// m_planWidth = width;
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setActualStartupTime(float timems)
|
||||
//{
|
||||
// m_actualStartupTime = timems;
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setActualTotalTime(float timems)
|
||||
//{
|
||||
// m_actualTotalTime = timems;
|
||||
//}
|
||||
|
||||
//float ExplainTreeModelItem::actualTotalTime() const
|
||||
//{
|
||||
// return m_actualTotalTime;
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setActualRows(long long rowcount)
|
||||
//{
|
||||
// m_actualRows = rowcount;
|
||||
//}
|
||||
|
||||
//long long ExplainTreeModelItem::actualRows() const
|
||||
//{
|
||||
// return m_actualRows;
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setActualLoops(int loopcount)
|
||||
//{
|
||||
// m_actualLoops = loopcount;
|
||||
//}
|
||||
|
||||
//int ExplainTreeModelItem::actualLoops() const
|
||||
//{
|
||||
// return m_actualLoops;
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setRelationName(QString n)
|
||||
//{
|
||||
// m_relationName = std::move(n);
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setAlias(QString a)
|
||||
//{
|
||||
// m_alias = std::move(a);
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setScanDirection(QString dir)
|
||||
//{
|
||||
// m_scanDirection = std::move(dir);
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setIndexName(QString idxname)
|
||||
//{
|
||||
// m_indexName = std::move(idxname);
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setIndexCondition(QString idxcond)
|
||||
//{
|
||||
// m_indexCondition = std::move(idxcond);
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setIndexRecheck(QString idxrecheck)
|
||||
//{
|
||||
// m_indexRecheck = std::move(idxrecheck);
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setFilter(QString filter)
|
||||
//{
|
||||
// m_filter = std::move(filter);
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setHashCondition(QString condition)
|
||||
//{
|
||||
// m_hashCondition = std::move(condition);
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setSortKey(QString key)
|
||||
//{
|
||||
// m_sortKey = std::move(key);
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setSortMethod(QString method)
|
||||
//{
|
||||
// m_sortMethod = std::move(method);
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setSortSpaceUsed(int space)
|
||||
//{
|
||||
// m_sortSpaceUsed = space;
|
||||
//}
|
||||
|
||||
//void ExplainTreeModelItem::setSortSpaceType(QString type)
|
||||
//{
|
||||
// m_sortSpaceType = std::move(type);
|
||||
//}
|
||||
|
||||
float ExplainTreeModelItem::exclusiveTime() const
|
||||
{
|
||||
float tt = inclusiveTime();
|
||||
for (auto c : m_childItems) {
|
||||
tt -= c->inclusiveTime();
|
||||
}
|
||||
return tt;
|
||||
}
|
||||
|
||||
float ExplainTreeModelItem::inclusiveTime() const
|
||||
{
|
||||
float t = actualTotalTime * actualLoops;
|
||||
return t;
|
||||
}
|
||||
|
||||
float ExplainTreeModelItem::estimateError() const
|
||||
{
|
||||
float res = 1.0;
|
||||
if (estimatedRows > actualRows) {
|
||||
if (actualRows > 0) {
|
||||
res = float(estimatedRows) / actualRows;
|
||||
}
|
||||
else {
|
||||
res = std::numeric_limits<float>::infinity();
|
||||
}
|
||||
}
|
||||
else if (actualRows > estimatedRows) {
|
||||
if (estimatedRows > 0) {
|
||||
res = float(actualRows) / estimatedRows;
|
||||
}
|
||||
else {
|
||||
res = std::numeric_limits<float>::infinity();
|
||||
}
|
||||
res = -res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
QString ExplainTreeModelItem::detailString() const
|
||||
{
|
||||
QString s;
|
||||
if (!joinType.isEmpty()) {
|
||||
s += joinType + " " + nodeType + " ";
|
||||
}
|
||||
if (!strategy.isEmpty()) {
|
||||
s += strategy + " " + nodeType + " ";
|
||||
}
|
||||
if (!indexName.isEmpty()) {
|
||||
s+= scanDirection + " "
|
||||
+ nodeType + "\n";
|
||||
if (!indexCondition.isEmpty()) {
|
||||
s += "cond: " + indexCondition + " ";
|
||||
}
|
||||
if (!filter.isEmpty()) {
|
||||
s += "filter: " + filter + "\n";
|
||||
}
|
||||
if (!indexRecheck.isEmpty()) {
|
||||
s += "removed by recheck: " + indexRecheck + "\n";
|
||||
}
|
||||
s += "idx: " + indexName + " rel: " + alias + " ";
|
||||
}
|
||||
else {
|
||||
if (!alias.isEmpty()) {
|
||||
s += nodeType + " rel: " + alias + " ";
|
||||
}
|
||||
}
|
||||
if (!hashCondition.isEmpty()) {
|
||||
s += hashCondition + " ";
|
||||
}
|
||||
if (!sortMethod.isEmpty()) {
|
||||
s += sortMethod + " " + sortSpaceType + " "
|
||||
+ QString::number(sortSpaceUsed) + "kB "
|
||||
+ sortKey + " ";
|
||||
|
||||
}
|
||||
|
||||
return s.trimmed();
|
||||
}
|
||||
|
||||
//"Sort Key": ["pg_attribute.attname"],
|
||||
//"Sort Method": "quicksort",
|
||||
//"Sort Space Used": 1426,
|
||||
//"Sort Space Type": "Memory",
|
||||
|
||||
|
||||
//{
|
||||
// "Node Type": "Index Scan",
|
||||
// "Parent Relationship": "Inner",
|
||||
// "Scan Direction": "Forward",
|
||||
// "Index Name": "pg_type_oid_index",
|
||||
// "Relation Name": "pg_type",
|
||||
// "Alias": "pg_type",
|
||||
// "Startup Cost": 0.15,
|
||||
// "Total Cost": 0.18,
|
||||
// "Plan Rows": 1,
|
||||
// "Plan Width": 758,
|
||||
// "Actual Startup Time": 0.003,
|
||||
// "Actual Total Time": 0.004,
|
||||
// "Actual Rows": 1,
|
||||
// "Actual Loops": 100,
|
||||
// "Index Cond": "(oid = pg_attribute.atttypid)",
|
||||
// "Rows Removed by Index Recheck": 0
|
||||
// "Filter": "actief"
|
||||
//}
|
||||
163
core/ExplainTreeModelItem.h
Normal file
163
core/ExplainTreeModelItem.h
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
#pragma once
|
||||
|
||||
#include <QList>
|
||||
//#include <QVariant>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
namespace Json {
|
||||
|
||||
class Value;
|
||||
|
||||
}
|
||||
class ExplainTreeModelItem;
|
||||
typedef std::shared_ptr<ExplainTreeModelItem> ExplainTreeModelItemPtr;
|
||||
|
||||
/* Columns for tree
|
||||
* 0. explain text
|
||||
* 1. exclusive times
|
||||
* 2. inclusive
|
||||
* 3. rows x
|
||||
* 4. rows
|
||||
* 5. loops
|
||||
*/
|
||||
|
||||
/** \brief Class for the nodes in the QueryExplainModel
|
||||
*/
|
||||
class ExplainTreeModelItem: public std::enable_shared_from_this<ExplainTreeModelItem> {
|
||||
public:
|
||||
typedef std::shared_ptr<ExplainTreeModelItem> ItemPtr;
|
||||
|
||||
struct Buffer {
|
||||
int hit = 0;
|
||||
int read = 0;
|
||||
int dirtied = 0;
|
||||
int written = 0;
|
||||
|
||||
QString asString() const
|
||||
{
|
||||
return QString::asprintf("h %d/r %d/d %d/w %d", hit, read, dirtied, written);
|
||||
}
|
||||
};
|
||||
|
||||
struct TempBlocks {
|
||||
int read = 0;
|
||||
int written = 0;
|
||||
};
|
||||
|
||||
struct IoTimes {
|
||||
double read = 0.0;
|
||||
double write =0.0;
|
||||
};
|
||||
|
||||
ExplainTreeModelItem();
|
||||
~ExplainTreeModelItem();
|
||||
|
||||
ExplainTreeModelItem(const ExplainTreeModelItem &rhs) = delete;
|
||||
ExplainTreeModelItem &operator=(const ExplainTreeModelItem &rhs) = delete;
|
||||
|
||||
void appendChild(ItemPtr child);
|
||||
|
||||
ExplainTreeModelItemPtr child(int row);
|
||||
int childCount() const;
|
||||
// int columnCount() const;
|
||||
// QVariant data(int column) const;
|
||||
int row() const;
|
||||
void setParent(ItemPtr parent);
|
||||
ItemPtr parent();
|
||||
|
||||
|
||||
// void setNodeType(QString nt);
|
||||
// const QString& nodeType() const;
|
||||
// void setParallelAware(bool aware);
|
||||
// bool getParallelAware() const;
|
||||
// void setStrategy(QString strat);
|
||||
// const QString& strategy() const;
|
||||
// void setJoinType(QString jointype);
|
||||
// QString joinType() const;
|
||||
// void setStartupCost(float cost);
|
||||
// void setTotalCost(float cost);
|
||||
// void setEstimatedRows(long long estimated);
|
||||
// long long estimatedRows() const;
|
||||
// void setPlanWidth(int width);
|
||||
// void setActualStartupTime(float timems);
|
||||
// void setActualTotalTime(float timems);
|
||||
// float actualTotalTime() const;
|
||||
// void setActualRows(long long rowcount);
|
||||
// long long actualRows() const;
|
||||
// void setActualLoops(int loopcount);
|
||||
// int actualLoops() const;
|
||||
|
||||
// void setRelationName(QString n);
|
||||
// void setAlias(QString a);
|
||||
// void setScanDirection(QString dir);
|
||||
// void setIndexName(QString idxname);
|
||||
// void setIndexCondition(QString idxcond);
|
||||
// void setIndexRecheck(QString idxrecheck);
|
||||
// void setFilter(QString filter);
|
||||
// void setHashCondition(QString condition);
|
||||
// void setSortKey(QString key);
|
||||
// void setSortMethod(QString method);
|
||||
// void setSortSpaceUsed(int space);
|
||||
// void setSortSpaceType(QString type);
|
||||
|
||||
/** ActualTotalTime minus the actual total time of it's children */
|
||||
float exclusiveTime() const;
|
||||
float inclusiveTime() const;
|
||||
float estimateError() const;
|
||||
QString detailString() const;
|
||||
|
||||
//private:
|
||||
std::vector<ItemPtr> m_childItems;
|
||||
std::weak_ptr<ExplainTreeModelItem> m_parentItem;
|
||||
|
||||
QString nodeType;
|
||||
bool parallelAware; // 9.6
|
||||
QString strategy;
|
||||
QString joinType;
|
||||
float startupCost = 0.f;
|
||||
float totalCost = 0.f;
|
||||
int64_t estimatedRows = 0;
|
||||
int planWidth = 0;
|
||||
float actualStartupTime = 0.f;
|
||||
float actualTotalTime = 0.f;
|
||||
int64_t actualRows = 0;
|
||||
int actualLoops = 0;
|
||||
|
||||
QString relationName;
|
||||
QString alias;
|
||||
QString scanDirection;
|
||||
QString indexName;
|
||||
QString indexCondition;
|
||||
QString indexRecheck;
|
||||
QString filter;
|
||||
QString hashCondition;
|
||||
QString sortKey;
|
||||
QString sortMethod;
|
||||
int sortSpaceUsed = -1;
|
||||
QString sortSpaceType;
|
||||
|
||||
// Buffering related
|
||||
Buffer sharedBlocks;
|
||||
Buffer localBlocks;
|
||||
TempBlocks tempBlocks;
|
||||
IoTimes ioTimes;
|
||||
|
||||
// "Triggers": [
|
||||
// ],
|
||||
|
||||
};
|
||||
|
||||
class ExplainRoot {
|
||||
public:
|
||||
using SPtr = std::shared_ptr<ExplainRoot>;
|
||||
static SPtr createFromJson(Json::Value &json);
|
||||
|
||||
ExplainTreeModelItemPtr plan;
|
||||
float planningTime = 0.f;
|
||||
// Triggers???
|
||||
float executionTime = 0.f;
|
||||
float totalRuntime = 0.f;
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -31,7 +31,9 @@ SOURCES += my_boost_assert_handler.cpp \
|
|||
PasswordManager.cpp \
|
||||
CsvWriter.cpp \
|
||||
BackupFormatModel.cpp \
|
||||
QueuedBackgroundTask.cpp
|
||||
QueuedBackgroundTask.cpp \
|
||||
ExplainTreeModelItem.cpp \
|
||||
jsoncpp.cpp
|
||||
|
||||
HEADERS += PasswordManager.h \
|
||||
SqlLexer.h \
|
||||
|
|
@ -39,9 +41,12 @@ HEADERS += PasswordManager.h \
|
|||
CsvWriter.h \
|
||||
BackupFormatModel.h \
|
||||
QueuedBackgroundTask.h \
|
||||
Expected.h
|
||||
Expected.h \
|
||||
ExplainTreeModelItem.h
|
||||
|
||||
unix {
|
||||
target.path = /usr/lib
|
||||
INSTALLS += target
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
330
core/json/json-forwards.h
Normal file
330
core/json/json-forwards.h
Normal file
|
|
@ -0,0 +1,330 @@
|
|||
/// 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
|
||||
#include <stddef.h>
|
||||
#include <string> //typedef String
|
||||
#include <stdint.h> //typedef int64_t, uint64_t
|
||||
|
||||
/// 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) || defined(__MINGW32__)
|
||||
#define JSON_API __declspec(dllexport)
|
||||
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||
#endif // if defined(_MSC_VER)
|
||||
#elif defined(JSON_DLL)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#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) // MSVC
|
||||
# if _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 // MSVC 6
|
||||
|
||||
# if _MSC_VER >= 1500 // MSVC 2008
|
||||
/// Indicates that the following function is deprecated.
|
||||
# define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
|
||||
# endif
|
||||
|
||||
#endif // defined(_MSC_VER)
|
||||
|
||||
// In c++11 the override keyword allows you to explicity define that a function
|
||||
// is intended to override the base-class version. This makes the code more
|
||||
// managable and fixes a set of common hard-to-find bugs.
|
||||
#if __cplusplus >= 201103L
|
||||
# define JSONCPP_OVERRIDE override
|
||||
# define JSONCPP_NOEXCEPT noexcept
|
||||
#elif defined(_MSC_VER) && _MSC_VER > 1600 && _MSC_VER < 1900
|
||||
# define JSONCPP_OVERRIDE override
|
||||
# define JSONCPP_NOEXCEPT throw()
|
||||
#elif defined(_MSC_VER) && _MSC_VER >= 1900
|
||||
# define JSONCPP_OVERRIDE override
|
||||
# define JSONCPP_NOEXCEPT noexcept
|
||||
#else
|
||||
# define JSONCPP_OVERRIDE
|
||||
# define JSONCPP_NOEXCEPT throw()
|
||||
#endif
|
||||
|
||||
#ifndef JSON_HAS_RVALUE_REFERENCES
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
|
||||
#define JSON_HAS_RVALUE_REFERENCES 1
|
||||
#endif // MSVC >= 2010
|
||||
|
||||
#ifdef __clang__
|
||||
#if __has_feature(cxx_rvalue_references)
|
||||
#define JSON_HAS_RVALUE_REFERENCES 1
|
||||
#endif // has_feature
|
||||
|
||||
#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
|
||||
#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
|
||||
#define JSON_HAS_RVALUE_REFERENCES 1
|
||||
#endif // GXX_EXPERIMENTAL
|
||||
|
||||
#endif // __clang__ || __GNUC__
|
||||
|
||||
#endif // not defined JSON_HAS_RVALUE_REFERENCES
|
||||
|
||||
#ifndef JSON_HAS_RVALUE_REFERENCES
|
||||
#define JSON_HAS_RVALUE_REFERENCES 0
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
|
||||
# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
|
||||
# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
|
||||
# elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
# define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
|
||||
# endif // GNUC version
|
||||
#endif // __clang__ || __GNUC__
|
||||
|
||||
#if !defined(JSONCPP_DEPRECATED)
|
||||
#define JSONCPP_DEPRECATED(message)
|
||||
#endif // if !defined(JSONCPP_DEPRECATED)
|
||||
|
||||
#if __GNUC__ >= 6
|
||||
# define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
||||
#endif
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
# include "version.h"
|
||||
|
||||
# if JSONCPP_USING_SECURE_MEMORY
|
||||
# include "allocator.h" //typedef Allocator
|
||||
# endif
|
||||
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
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 int64_t Int64;
|
||||
typedef uint64_t UInt64;
|
||||
#endif // if defined(_MSC_VER)
|
||||
typedef Int64 LargestInt;
|
||||
typedef UInt64 LargestUInt;
|
||||
#define JSON_HAS_INT64
|
||||
#endif // if defined(JSON_NO_INT64)
|
||||
#if JSONCPP_USING_SECURE_MEMORY
|
||||
#define JSONCPP_STRING std::basic_string<char, std::char_traits<char>, Json::SecureAllocator<char> >
|
||||
#define JSONCPP_OSTRINGSTREAM std::basic_ostringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
|
||||
#define JSONCPP_OSTREAM std::basic_ostream<char, std::char_traits<char>>
|
||||
#define JSONCPP_ISTRINGSTREAM std::basic_istringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
|
||||
#define JSONCPP_ISTREAM std::istream
|
||||
#else
|
||||
#define JSONCPP_STRING std::string
|
||||
#define JSONCPP_OSTRINGSTREAM std::ostringstream
|
||||
#define JSONCPP_OSTREAM std::ostream
|
||||
#define JSONCPP_ISTRINGSTREAM std::istringstream
|
||||
#define JSONCPP_ISTREAM std::istream
|
||||
#endif // if JSONCPP_USING_SECURE_MEMORY
|
||||
} // 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
|
||||
2161
core/json/json.h
Normal file
2161
core/json/json.h
Normal file
File diff suppressed because it is too large
Load diff
5311
core/jsoncpp.cpp
Normal file
5311
core/jsoncpp.cpp
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue