mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-19 10:35:50 +00:00
Move streaming Json objects to ripple/json.
This commit is contained in:
@@ -2267,10 +2267,19 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\json\impl\Object.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\json\impl\Output.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\json\impl\to_string.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\json\impl\Writer.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\json\JsonPropertyStream.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\json\json_forwards.h">
|
||||
@@ -2281,12 +2290,27 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\json\json_writer.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\json\Object.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\json\Output.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\json\tests\JsonCpp.test.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\json\tests\Object.test.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\json\tests\Output.test.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\json\tests\Writer.test.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\json\to_string.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\json\Writer.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\net\HTTPClient.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\net\HTTPRequest.h">
|
||||
@@ -3116,16 +3140,6 @@
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\impl\Handler.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\impl\JsonObject.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\impl\JsonObject.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\impl\JsonWriter.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\impl\JsonWriter.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\impl\KeypairForSignature.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
@@ -3168,11 +3182,6 @@
|
||||
<ClCompile Include="..\..\src\ripple\rpc\impl\Utilities.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\impl\WriteJson.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\impl\WriteJson.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\impl\Yield.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
@@ -3180,8 +3189,6 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\Manager.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\Output.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\Request.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\RPCHandler.h">
|
||||
@@ -3193,15 +3200,9 @@
|
||||
<ClCompile Include="..\..\src\ripple\rpc\tests\Coroutine.test.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\tests\JsonObject.test.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\tests\JSONRPC.test.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\tests\JsonWriter.test.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\tests\KeyGeneration.test.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
@@ -3210,9 +3211,6 @@
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\tests\TestOutputSuite.test.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\tests\WriteJson.test.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\tests\Yield.test.cpp">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
|
||||
@@ -3024,9 +3024,18 @@
|
||||
<ClCompile Include="..\..\src\ripple\json\impl\json_writer.cpp">
|
||||
<Filter>ripple\json\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\json\impl\Object.cpp">
|
||||
<Filter>ripple\json\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\json\impl\Output.cpp">
|
||||
<Filter>ripple\json\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\json\impl\to_string.cpp">
|
||||
<Filter>ripple\json\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\json\impl\Writer.cpp">
|
||||
<Filter>ripple\json\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\json\JsonPropertyStream.h">
|
||||
<Filter>ripple\json</Filter>
|
||||
</ClInclude>
|
||||
@@ -3042,12 +3051,30 @@
|
||||
<ClInclude Include="..\..\src\ripple\json\json_writer.h">
|
||||
<Filter>ripple\json</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\json\Object.h">
|
||||
<Filter>ripple\json</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\json\Output.h">
|
||||
<Filter>ripple\json</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\json\tests\JsonCpp.test.cpp">
|
||||
<Filter>ripple\json\tests</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\json\tests\Object.test.cpp">
|
||||
<Filter>ripple\json\tests</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\json\tests\Output.test.cpp">
|
||||
<Filter>ripple\json\tests</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\json\tests\Writer.test.cpp">
|
||||
<Filter>ripple\json\tests</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\json\to_string.h">
|
||||
<Filter>ripple\json</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\json\Writer.h">
|
||||
<Filter>ripple\json</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\net\HTTPClient.h">
|
||||
<Filter>ripple\net</Filter>
|
||||
</ClInclude>
|
||||
@@ -3876,18 +3903,6 @@
|
||||
<ClInclude Include="..\..\src\ripple\rpc\impl\Handler.h">
|
||||
<Filter>ripple\rpc\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\impl\JsonObject.cpp">
|
||||
<Filter>ripple\rpc\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\impl\JsonObject.h">
|
||||
<Filter>ripple\rpc\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\impl\JsonWriter.cpp">
|
||||
<Filter>ripple\rpc\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\impl\JsonWriter.h">
|
||||
<Filter>ripple\rpc\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\impl\KeypairForSignature.cpp">
|
||||
<Filter>ripple\rpc\impl</Filter>
|
||||
</ClCompile>
|
||||
@@ -3936,12 +3951,6 @@
|
||||
<ClCompile Include="..\..\src\ripple\rpc\impl\Utilities.cpp">
|
||||
<Filter>ripple\rpc\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\impl\WriteJson.cpp">
|
||||
<Filter>ripple\rpc\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\impl\WriteJson.h">
|
||||
<Filter>ripple\rpc\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\impl\Yield.cpp">
|
||||
<Filter>ripple\rpc\impl</Filter>
|
||||
</ClCompile>
|
||||
@@ -3951,9 +3960,6 @@
|
||||
<ClInclude Include="..\..\src\ripple\rpc\Manager.h">
|
||||
<Filter>ripple\rpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\Output.h">
|
||||
<Filter>ripple\rpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\rpc\Request.h">
|
||||
<Filter>ripple\rpc</Filter>
|
||||
</ClInclude>
|
||||
@@ -3969,15 +3975,9 @@
|
||||
<ClCompile Include="..\..\src\ripple\rpc\tests\Coroutine.test.cpp">
|
||||
<Filter>ripple\rpc\tests</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\tests\JsonObject.test.cpp">
|
||||
<Filter>ripple\rpc\tests</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\tests\JSONRPC.test.cpp">
|
||||
<Filter>ripple\rpc\tests</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\tests\JsonWriter.test.cpp">
|
||||
<Filter>ripple\rpc\tests</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\tests\KeyGeneration.test.cpp">
|
||||
<Filter>ripple\rpc\tests</Filter>
|
||||
</ClCompile>
|
||||
@@ -3987,9 +3987,6 @@
|
||||
<ClInclude Include="..\..\src\ripple\rpc\tests\TestOutputSuite.test.h">
|
||||
<Filter>ripple\rpc\tests</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\tests\WriteJson.test.cpp">
|
||||
<Filter>ripple\rpc\tests</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\rpc\tests\Yield.test.cpp">
|
||||
<Filter>ripple\rpc\tests</Filter>
|
||||
</ClCompile>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <ripple/protocol/JsonFields.h>
|
||||
#include <ripple/protocol/STTx.h>
|
||||
#include <ripple/rpc/Yield.h>
|
||||
#include <ripple/rpc/impl/JsonObject.h>
|
||||
#include <ripple/json/Object.h>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
namespace ripple {
|
||||
@@ -118,7 +118,7 @@ void fillJson (Object& json, LedgerFill const& fill)
|
||||
auto &transactionMap = ledger.peekTransactionMap();
|
||||
if (transactionMap && (bFull || fill.options & LedgerFill::dumpTxrp))
|
||||
{
|
||||
auto&& txns = RPC::setArray (json, jss::transactions);
|
||||
auto&& txns = Json::setArray (json, jss::transactions);
|
||||
SHAMapTreeNode::TNType type;
|
||||
|
||||
RPC::CountedYield count (
|
||||
@@ -163,7 +163,7 @@ void fillJson (Object& json, LedgerFill const& fill)
|
||||
auto& accountStateMap = ledger.peekAccountStateMap();
|
||||
if (accountStateMap && (bFull || fill.options & LedgerFill::dumpState))
|
||||
{
|
||||
auto&& array = RPC::setArray (json, jss::accountState);
|
||||
auto&& array = Json::setArray (json, jss::accountState);
|
||||
RPC::CountedYield count (
|
||||
fill.yieldStrategy.accountYieldCount, fill.yield);
|
||||
if (bFull || bExpand)
|
||||
@@ -191,7 +191,7 @@ void fillJson (Object& json, LedgerFill const& fill)
|
||||
template <class Object>
|
||||
void addJson (Object& json, LedgerFill const& fill)
|
||||
{
|
||||
auto&& object = RPC::addObject (json, jss::ledger);
|
||||
auto&& object = Json::addObject (json, jss::ledger);
|
||||
fillJson (object, fill);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
#ifndef RIPPLE_RPC_JSONOBJECT_H_INCLUDED
|
||||
#define RIPPLE_RPC_JSONOBJECT_H_INCLUDED
|
||||
|
||||
#include <ripple/rpc/impl/JsonWriter.h>
|
||||
#include <ripple/json/Writer.h>
|
||||
#include <beast/cxx14/memory.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
namespace Json {
|
||||
|
||||
/**
|
||||
Collection is a base class for Array and Object, classes which provide the
|
||||
@@ -489,7 +489,6 @@ Object appendObject (Array& json)
|
||||
return json.appendObject ();
|
||||
}
|
||||
|
||||
} // RPC
|
||||
} // ripple
|
||||
} // Json
|
||||
|
||||
#endif
|
||||
@@ -17,27 +17,35 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_RPC_WRITEJSON_H_INCLUDED
|
||||
#define RIPPLE_RPC_WRITEJSON_H_INCLUDED
|
||||
#ifndef RIPPLE_JSON_OUTPUT_H_INCLUDED
|
||||
#define RIPPLE_JSON_OUTPUT_H_INCLUDED
|
||||
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
#include <boost/utility/string_ref.hpp>
|
||||
|
||||
namespace Json {
|
||||
|
||||
using Output = std::function <void (boost::string_ref const&)>;
|
||||
|
||||
inline
|
||||
Output stringOutput (std::string& s)
|
||||
{
|
||||
return [&](boost::string_ref const& b) { s.append (b.data(), b.size()); };
|
||||
}
|
||||
|
||||
/** Writes a minimal representation of a Json value to an Output in O(n) time.
|
||||
|
||||
Data is streamed right to the output, so only a marginal amount of memory is
|
||||
used. This can be very important for a very large Json::Value.
|
||||
*/
|
||||
void writeJson (Json::Value const&, Output const&);
|
||||
void outputJson (Json::Value const&, Output const&);
|
||||
|
||||
/** Return the minimal string representation of a Json::Value in O(n) time.
|
||||
|
||||
This requires a memory allocation for the full size of the output.
|
||||
If possible, use write().
|
||||
If possible, use outputJson().
|
||||
*/
|
||||
std::string jsonAsString (Json::Value const&);
|
||||
|
||||
} // RPC
|
||||
} // ripple
|
||||
} // Json
|
||||
|
||||
#endif
|
||||
@@ -21,12 +21,12 @@
|
||||
#define RIPPLE_RPC_JSONWRITER_H_INCLUDED
|
||||
|
||||
#include <ripple/basics/ToString.h>
|
||||
#include <ripple/json/Output.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/rpc/Output.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <memory>
|
||||
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
namespace Json {
|
||||
|
||||
/**
|
||||
* Writer implements an O(1)-space, O(1)-granular output JSON writer.
|
||||
@@ -204,11 +204,11 @@ public:
|
||||
template <typename Type>
|
||||
void output (Type t)
|
||||
{
|
||||
implOutput (to_string (t));
|
||||
implOutput (ripple::to_string (t));
|
||||
}
|
||||
|
||||
/** Output an error code. */
|
||||
void output (error_code_i t)
|
||||
void output (ripple::error_code_i t)
|
||||
{
|
||||
output (int(t));
|
||||
}
|
||||
@@ -244,7 +244,6 @@ inline void check (bool condition, std::string const& message)
|
||||
throw JsonException (message);
|
||||
}
|
||||
|
||||
} // RPC
|
||||
} // ripple
|
||||
} // Json
|
||||
|
||||
#endif
|
||||
@@ -18,10 +18,9 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/rpc/impl/JsonObject.h>
|
||||
#include <ripple/json/Object.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
namespace Json {
|
||||
|
||||
Collection::Collection (Collection* parent, Writer* writer)
|
||||
: parent_ (parent), writer_ (writer), enabled_ (true)
|
||||
@@ -157,5 +156,4 @@ WriterObject stringWriterObject (std::string& s)
|
||||
return WriterObject (stringOutput (s));
|
||||
}
|
||||
|
||||
} // RPC
|
||||
} // ripple
|
||||
} // Json
|
||||
@@ -18,15 +18,14 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/rpc/impl/WriteJson.h>
|
||||
#include <ripple/rpc/impl/JsonWriter.h>
|
||||
#include <ripple/json/Output.h>
|
||||
#include <ripple/json/Writer.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
namespace Json {
|
||||
|
||||
namespace {
|
||||
|
||||
void writeJson (Json::Value const& value, Writer& writer)
|
||||
void outputJson (Json::Value const& value, Writer& writer)
|
||||
{
|
||||
switch (value.type())
|
||||
{
|
||||
@@ -72,7 +71,7 @@ void writeJson (Json::Value const& value, Writer& writer)
|
||||
for (auto const& i: value)
|
||||
{
|
||||
writer.rawAppend();
|
||||
writeJson (i, writer);
|
||||
outputJson (i, writer);
|
||||
}
|
||||
writer.finish();
|
||||
break;
|
||||
@@ -85,7 +84,7 @@ void writeJson (Json::Value const& value, Writer& writer)
|
||||
for (auto const& tag: members)
|
||||
{
|
||||
writer.rawSet (tag);
|
||||
writeJson (value[tag], writer);
|
||||
outputJson (value[tag], writer);
|
||||
}
|
||||
writer.finish();
|
||||
break;
|
||||
@@ -95,19 +94,18 @@ void writeJson (Json::Value const& value, Writer& writer)
|
||||
|
||||
} // namespace
|
||||
|
||||
void writeJson (Json::Value const& value, Output const& out)
|
||||
void outputJson (Json::Value const& value, Output const& out)
|
||||
{
|
||||
Writer writer (out);
|
||||
writeJson (value, writer);
|
||||
outputJson (value, writer);
|
||||
}
|
||||
|
||||
std::string jsonAsString (Json::Value const& value)
|
||||
{
|
||||
std::string s;
|
||||
Writer writer (stringOutput (s));
|
||||
writeJson (value, writer);
|
||||
outputJson (value, writer);
|
||||
return s;
|
||||
}
|
||||
|
||||
} // RPC
|
||||
} // ripple
|
||||
} // Json
|
||||
@@ -18,12 +18,11 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/rpc/impl/JsonWriter.h>
|
||||
#include <ripple/rpc/impl/WriteJson.h>
|
||||
#include <ripple/json/Output.h>
|
||||
#include <ripple/json/Writer.h>
|
||||
#include <beast/unit_test/suite.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
namespace Json {
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -244,20 +243,20 @@ void Writer::output (std::string const& s)
|
||||
void Writer::output (Json::Value const& value)
|
||||
{
|
||||
impl_->markStarted();
|
||||
writeJson (value, impl_->getOutput());
|
||||
outputJson (value, impl_->getOutput());
|
||||
}
|
||||
|
||||
template <>
|
||||
void Writer::output (float f)
|
||||
{
|
||||
auto s = to_string (f);
|
||||
auto s = ripple::to_string (f);
|
||||
impl_->output ({s.data (), lengthWithoutTrailingZeros (s)});
|
||||
}
|
||||
|
||||
template <>
|
||||
void Writer::output (double f)
|
||||
{
|
||||
auto s = to_string (f);
|
||||
auto s = ripple::to_string (f);
|
||||
impl_->output ({s.data (), lengthWithoutTrailingZeros (s)});
|
||||
}
|
||||
|
||||
@@ -315,5 +314,4 @@ void Writer::finish ()
|
||||
impl_->finish ();
|
||||
}
|
||||
|
||||
} // RPC
|
||||
} // ripple
|
||||
} // Json
|
||||
@@ -178,13 +178,6 @@ std::string valueToQuotedString ( const char* value )
|
||||
return result;
|
||||
}
|
||||
|
||||
// Class Writer
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
Writer::~Writer ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Class FastWriter
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -31,11 +31,10 @@ class Value;
|
||||
|
||||
/** \brief Abstract class for writers.
|
||||
*/
|
||||
class Writer
|
||||
class WriterBase
|
||||
{
|
||||
public:
|
||||
virtual ~Writer ();
|
||||
|
||||
virtual ~WriterBase () {}
|
||||
virtual std::string write ( const Value& root ) = 0;
|
||||
};
|
||||
|
||||
@@ -45,7 +44,8 @@ public:
|
||||
* but may be usefull to support feature such as RPC where bandwith is limited.
|
||||
* \sa Reader, Value
|
||||
*/
|
||||
class FastWriter : public Writer
|
||||
|
||||
class FastWriter : public WriterBase
|
||||
{
|
||||
public:
|
||||
FastWriter ();
|
||||
@@ -78,7 +78,7 @@ private:
|
||||
*
|
||||
* \sa Reader, Value, Value::setComment()
|
||||
*/
|
||||
class StyledWriter: public Writer
|
||||
class StyledWriter: public WriterBase
|
||||
{
|
||||
public:
|
||||
StyledWriter ();
|
||||
|
||||
@@ -18,14 +18,13 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/rpc/impl/JsonObject.h>
|
||||
#include <ripple/json/Object.h>
|
||||
#include <ripple/rpc/tests/TestOutputSuite.test.h>
|
||||
#include <beast/unit_test/suite.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
namespace Json {
|
||||
|
||||
class JsonObject_test : public TestOutputSuite
|
||||
class JsonObject_test : public ripple::RPC::TestOutputSuite
|
||||
{
|
||||
void setup (std::string const& testName)
|
||||
{
|
||||
@@ -240,5 +239,4 @@ public:
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(JsonObject, ripple_basics, ripple);
|
||||
|
||||
} // RPC
|
||||
} // ripple
|
||||
} // Json
|
||||
@@ -18,13 +18,12 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/rpc/impl/WriteJson.h>
|
||||
#include <ripple/json/Output.h>
|
||||
#include <ripple/rpc/tests/TestOutputSuite.test.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
namespace Json {
|
||||
|
||||
struct WriteJson_test : TestOutputSuite
|
||||
struct Output_test : ripple::RPC::TestOutputSuite
|
||||
{
|
||||
void runTest (std::string const& name, std::string const& valueDesc)
|
||||
{
|
||||
@@ -32,7 +31,7 @@ struct WriteJson_test : TestOutputSuite
|
||||
Json::Value value;
|
||||
expect (Json::Reader().parse (valueDesc, value));
|
||||
auto out = stringOutput (output_);
|
||||
writeJson (value, out);
|
||||
outputJson (value, out);
|
||||
|
||||
// Compare with the original version.
|
||||
auto expected = Json::FastWriter().write (value);
|
||||
@@ -63,7 +62,6 @@ struct WriteJson_test : TestOutputSuite
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(WriteJson, ripple_basics, ripple);
|
||||
BEAST_DEFINE_TESTSUITE(Output, ripple_basics, ripple);
|
||||
|
||||
} // RPC
|
||||
} // ripple
|
||||
} // Json
|
||||
@@ -19,14 +19,13 @@
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/json/json_writer.h>
|
||||
#include <ripple/rpc/impl/JsonWriter.h>
|
||||
#include <ripple/json/Writer.h>
|
||||
#include <ripple/rpc/tests/TestOutputSuite.test.h>
|
||||
#include <beast/unit_test/suite.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
namespace Json {
|
||||
|
||||
class JsonWriter_test : public TestOutputSuite
|
||||
class JsonWriter_test : public ripple::RPC::TestOutputSuite
|
||||
{
|
||||
public:
|
||||
void testTrivial ()
|
||||
@@ -203,5 +202,4 @@ public:
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(JsonWriter, ripple_basics, ripple);
|
||||
|
||||
} // RPC
|
||||
} // ripple
|
||||
} // Json
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include <beast/module/core/diagnostic/SemanticVersion.h>
|
||||
#include <ripple/protocol/JsonFields.h>
|
||||
#include <ripple/rpc/impl/JsonObject.h>
|
||||
#include <ripple/json/Object.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef RIPPLE_RPC_YIELD_H_INCLUDED
|
||||
#define RIPPLE_RPC_YIELD_H_INCLUDED
|
||||
|
||||
#include <ripple/rpc/Output.h>
|
||||
#include <ripple/json/Output.h>
|
||||
#include <boost/coroutine/all.hpp>
|
||||
#include <functional>
|
||||
|
||||
@@ -49,8 +49,8 @@ using Yield = std::function <void ()>;
|
||||
data. This is to avoid the case where you yield after outputting data, but
|
||||
then never send more data.
|
||||
*/
|
||||
Output chunkedYieldingOutput (
|
||||
Output const&, Yield const&, std::size_t chunkSize);
|
||||
Json::Output chunkedYieldingOutput (
|
||||
Json::Output const&, Yield const&, std::size_t chunkSize);
|
||||
|
||||
/** Yield every yieldCount calls. If yieldCount is 0, never yield. */
|
||||
class CountedYield
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/app/ledger/LedgerToJson.h>
|
||||
#include <ripple/core/LoadFeeTrack.h>
|
||||
#include <ripple/json/Object.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/rpc/handlers/Ledger.h>
|
||||
#include <ripple/rpc/impl/JsonObject.h>
|
||||
#include <ripple/server/Role.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -22,14 +22,16 @@
|
||||
|
||||
#include <ripple/app/ledger/LedgerToJson.h>
|
||||
#include <ripple/core/LoadFeeTrack.h>
|
||||
#include <ripple/rpc/impl/JsonObject.h>
|
||||
#include <ripple/json/Object.h>
|
||||
#include <ripple/server/Role.h>
|
||||
|
||||
namespace Json {
|
||||
class Object;
|
||||
}
|
||||
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
|
||||
class Object;
|
||||
|
||||
// ledger [id|index|current|closed] [full]
|
||||
// {
|
||||
// ledger: 'current' | 'closed' | <uint256> | <number>, // optional
|
||||
@@ -77,7 +79,7 @@ void LedgerHandler::writeResult (Object& value)
|
||||
{
|
||||
if (ledger_)
|
||||
{
|
||||
RPC::copyFrom (value, result_);
|
||||
Json::copyFrom (value, result_);
|
||||
addJson (value, {*ledger_, options_, context_.yield});
|
||||
}
|
||||
else
|
||||
@@ -85,11 +87,11 @@ void LedgerHandler::writeResult (Object& value)
|
||||
auto& master = getApp().getLedgerMaster ();
|
||||
auto& yield = context_.yield;
|
||||
{
|
||||
auto&& closed = RPC::addObject (value, jss::closed);
|
||||
auto&& closed = Json::addObject (value, jss::closed);
|
||||
addJson (closed, {*master.getClosedLedger(), 0, yield});
|
||||
}
|
||||
{
|
||||
auto&& open = RPC::addObject (value, jss::open);
|
||||
auto&& open = Json::addObject (value, jss::open);
|
||||
addJson (open, {*master.getCurrentLedger(), 0, yield});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef RIPPLED_RIPPLE_RPC_HANDLERS_WALLETPROPOSE_H
|
||||
#define RIPPLED_RIPPLE_RPC_HANDLERS_WALLETPROPOSE_H
|
||||
|
||||
#include <ripple/rpc/impl/JsonObject.h>
|
||||
#include <ripple/json/json_value.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
|
||||
@@ -85,11 +85,11 @@ class HandlerTable {
|
||||
assert (table_.find(HandlerImpl::name()) == table_.end());
|
||||
|
||||
Handler h;
|
||||
h.name_ = HandlerImpl::name(),
|
||||
h.valueMethod_ = &handle<Json::Value, HandlerImpl>,
|
||||
h.role_ = HandlerImpl::role(),
|
||||
h.condition_ = HandlerImpl::condition(),
|
||||
h.objectMethod_ = &handle<Object, HandlerImpl>;
|
||||
h.name_ = HandlerImpl::name();
|
||||
h.valueMethod_ = &handle<Json::Value, HandlerImpl>;
|
||||
h.role_ = HandlerImpl::role();
|
||||
h.condition_ = HandlerImpl::condition();
|
||||
h.objectMethod_ = &handle<Json::Object, HandlerImpl>;
|
||||
|
||||
table_[HandlerImpl::name()] = h;
|
||||
};
|
||||
|
||||
@@ -24,11 +24,13 @@
|
||||
#include <ripple/rpc/RPCHandler.h>
|
||||
#include <ripple/rpc/Status.h>
|
||||
|
||||
namespace Json {
|
||||
class Object;
|
||||
}
|
||||
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
|
||||
class Object;
|
||||
|
||||
// Under what condition can we call this RPC?
|
||||
enum Condition {
|
||||
NO_CONDITION = 0,
|
||||
@@ -46,7 +48,7 @@ struct Handler
|
||||
Method<Json::Value> valueMethod_;
|
||||
Role role_;
|
||||
RPC::Condition condition_;
|
||||
Method<Object> objectMethod_;
|
||||
Method<Json::Object> objectMethod_;
|
||||
};
|
||||
|
||||
const Handler* getHandler (std::string const&);
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
#include <ripple/rpc/Yield.h>
|
||||
#include <ripple/rpc/impl/Tuning.h>
|
||||
#include <ripple/rpc/impl/Handler.h>
|
||||
#include <ripple/rpc/impl/WriteJson.h>
|
||||
#include <ripple/app/ledger/LedgerMaster.h>
|
||||
#include <ripple/app/misc/NetworkOPs.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/core/Config.h>
|
||||
#include <ripple/core/JobQueue.h>
|
||||
#include <ripple/json/Object.h>
|
||||
#include <ripple/json/to_string.h>
|
||||
#include <ripple/net/InfoSub.h>
|
||||
#include <ripple/net/RPCErr.h>
|
||||
@@ -190,7 +190,7 @@ template <class Method, class Object>
|
||||
void getResult (
|
||||
Context& context, Method method, Object& object, std::string const& name)
|
||||
{
|
||||
auto&& result = addObject (object, jss::result);
|
||||
auto&& result = Json::addObject (object, jss::result);
|
||||
if (auto status = callMethod (context, method, name, result))
|
||||
{
|
||||
WriteLog (lsDEBUG, RPCErr) << "rpcError: " << status.toString();
|
||||
@@ -228,13 +228,13 @@ void executeRPC (
|
||||
boost::optional <Handler const&> handler;
|
||||
if (auto error = fillHandler (context, handler))
|
||||
{
|
||||
auto wo = stringWriterObject (output);
|
||||
auto&& sub = addObject (*wo, jss::result);
|
||||
auto wo = Json::stringWriterObject (output);
|
||||
auto&& sub = Json::addObject (*wo, jss::result);
|
||||
inject_error (error, sub);
|
||||
}
|
||||
else if (auto method = handler->objectMethod_)
|
||||
{
|
||||
auto wo = stringWriterObject (output);
|
||||
auto wo = Json::stringWriterObject (output);
|
||||
getResult (context, method, *wo, handler->name_);
|
||||
}
|
||||
else if (auto method = handler->valueMethod_)
|
||||
@@ -250,7 +250,7 @@ void executeRPC (
|
||||
{
|
||||
// Can't ever get here.
|
||||
assert (false);
|
||||
throw RPC::JsonException ("RPC handler with no method");
|
||||
throw Json::JsonException ("RPC handler with no method");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
|
||||
Output chunkedYieldingOutput (
|
||||
Output const& output, Yield const& yield, std::size_t chunkSize)
|
||||
Json::Output chunkedYieldingOutput (
|
||||
Json::Output const& output, Yield const& yield, std::size_t chunkSize)
|
||||
{
|
||||
auto count = std::make_shared <std::size_t> (0);
|
||||
return [chunkSize, count, output, yield] (boost::string_ref const& bytes)
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
setup (name);
|
||||
|
||||
std::string buffer;
|
||||
Output output = stringOutput (buffer);
|
||||
Json::Output output = Json::stringOutput (buffer);
|
||||
|
||||
auto coroutine = Coroutine ([=] (Yield yield)
|
||||
{
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
#ifndef RIPPLE_RPC_TESTOUTPUTSUITE_H_INCLUDED
|
||||
#define RIPPLE_RPC_TESTOUTPUTSUITE_H_INCLUDED
|
||||
|
||||
#include <ripple/rpc/Output.h>
|
||||
#include <ripple/rpc/impl/JsonWriter.h>
|
||||
#include <ripple/json/Output.h>
|
||||
#include <ripple/json/Writer.h>
|
||||
#include <ripple/basics/TestSuite.h>
|
||||
|
||||
namespace ripple {
|
||||
@@ -31,13 +31,14 @@ class TestOutputSuite : public TestSuite
|
||||
{
|
||||
protected:
|
||||
std::string output_;
|
||||
std::unique_ptr <Writer> writer_;
|
||||
std::unique_ptr <Json::Writer> writer_;
|
||||
|
||||
void setup (std::string const& testName)
|
||||
{
|
||||
testcase (testName);
|
||||
output_.clear ();
|
||||
writer_ = std::make_unique <Writer> (stringOutput (output_));
|
||||
writer_ = std::make_unique <Json::Writer> (
|
||||
Json::stringOutput (output_));
|
||||
}
|
||||
|
||||
// Test the result and report values.
|
||||
|
||||
@@ -32,7 +32,8 @@ struct Yield_test : TestOutputSuite
|
||||
std::string lastYield;
|
||||
|
||||
auto yield = [&]() { lastYield = output_; };
|
||||
auto output = chunkedYieldingOutput (stringOutput (output_), yield, 5);
|
||||
auto output = chunkedYieldingOutput (
|
||||
Json::stringOutput (output_), yield, 5);
|
||||
output ("hello");
|
||||
expectResult ("hello");
|
||||
expectEquals (lastYield, "");
|
||||
|
||||
@@ -45,7 +45,7 @@ std::string getHTTPHeaderTimestamp ()
|
||||
return std::string (buffer);
|
||||
}
|
||||
|
||||
void HTTPReply (int nStatus, std::string const& content, RPC::Output output)
|
||||
void HTTPReply (int nStatus, std::string const& content, Json::Output output)
|
||||
{
|
||||
if (ShouldLog (lsTRACE, RPC))
|
||||
{
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
#define RIPPLE_SERVER_JSONRPCUTIL_H_INCLUDED
|
||||
|
||||
#include <ripple/json/json_value.h>
|
||||
#include <ripple/rpc/Output.h>
|
||||
#include <ripple/json/Output.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
void HTTPReply (int nStatus, std::string const& strMsg, RPC::Output);
|
||||
void HTTPReply (int nStatus, std::string const& strMsg, Json::Output);
|
||||
|
||||
} // ripple
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ ServerHandlerImp::onHandoff (HTTP::Session& session,
|
||||
}
|
||||
|
||||
static inline
|
||||
RPC::Output makeOutput (HTTP::Session& session)
|
||||
Json::Output makeOutput (HTTP::Session& session)
|
||||
{
|
||||
return [&](boost::string_ref const& b)
|
||||
{
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
#define RIPPLE_SERVER_SERVERHANDLERIMP_H_INCLUDED
|
||||
|
||||
#include <ripple/core/Job.h>
|
||||
#include <ripple/json/Output.h>
|
||||
#include <ripple/server/ServerHandler.h>
|
||||
#include <ripple/server/Session.h>
|
||||
#include <ripple/rpc/Output.h>
|
||||
#include <ripple/rpc/RPCHandler.h>
|
||||
#include <ripple/app/main/CollectorManager.h>
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
~ServerHandlerImp();
|
||||
|
||||
private:
|
||||
using Output = RPC::Output;
|
||||
using Output = Json::Output;
|
||||
using Yield = RPC::Yield;
|
||||
|
||||
void
|
||||
|
||||
@@ -36,6 +36,13 @@
|
||||
#include <ripple/json/impl/json_value.cpp>
|
||||
#include <ripple/json/impl/json_writer.cpp>
|
||||
#include <ripple/json/impl/to_string.cpp>
|
||||
|
||||
#include <ripple/json/impl/JsonPropertyStream.cpp>
|
||||
#include <ripple/json/impl/Writer.cpp>
|
||||
#include <ripple/json/impl/Object.cpp>
|
||||
#include <ripple/json/impl/Output.cpp>
|
||||
|
||||
#include <ripple/json/tests/JsonCpp.test.cpp>
|
||||
#include <ripple/json/tests/Object.test.cpp>
|
||||
#include <ripple/json/tests/Output.test.cpp>
|
||||
#include <ripple/json/tests/Writer.test.cpp>
|
||||
|
||||
@@ -27,9 +27,6 @@
|
||||
#include <ripple/rpc/RPCHandler.h>
|
||||
|
||||
#include <ripple/rpc/impl/Coroutine.cpp>
|
||||
#include <ripple/rpc/impl/JsonObject.cpp>
|
||||
#include <ripple/rpc/impl/JsonWriter.cpp>
|
||||
#include <ripple/rpc/impl/WriteJson.cpp>
|
||||
#include <ripple/rpc/impl/Manager.cpp>
|
||||
#include <ripple/rpc/impl/RPCHandler.cpp>
|
||||
#include <ripple/rpc/impl/Status.cpp>
|
||||
@@ -107,10 +104,7 @@
|
||||
#include <ripple/rpc/impl/RPCVersion.cpp>
|
||||
|
||||
#include <ripple/rpc/tests/Coroutine.test.cpp>
|
||||
#include <ripple/rpc/tests/JsonObject.test.cpp>
|
||||
#include <ripple/rpc/tests/JSONRPC.test.cpp>
|
||||
#include <ripple/rpc/tests/JsonWriter.test.cpp>
|
||||
#include <ripple/rpc/tests/KeyGeneration.test.cpp>
|
||||
#include <ripple/rpc/tests/Status.test.cpp>
|
||||
#include <ripple/rpc/tests/WriteJson.test.cpp>
|
||||
#include <ripple/rpc/tests/Yield.test.cpp>
|
||||
|
||||
Reference in New Issue
Block a user