Split ripple_json to its own module

This commit is contained in:
Vinnie Falco
2013-09-19 20:51:51 -07:00
parent c3b815004c
commit b493db1d65
25 changed files with 715 additions and 673 deletions

View File

@@ -378,6 +378,7 @@ Value::Value ( const std::string& value )
(unsigned int)value.length () );
}
Value::Value (beast::String const& beastString)
: type_ ( stringValue )
, allocated_ ( true )
@@ -750,7 +751,7 @@ Value::asString () const
return value_.bool_ ? "true" : "false";
case intValue:
return lexicalCastThrow <std::string> (value_.int_);
return beast::lexicalCastThrow <std::string> (value_.int_);
case uintValue:
case realValue:
@@ -796,7 +797,7 @@ Value::asInt () const
return value_.bool_ ? 1 : 0;
case stringValue:
return lexicalCastThrow <int> (value_.string_);
return beast::lexicalCastThrow <int> (value_.string_);
case arrayValue:
case objectValue:
@@ -832,7 +833,7 @@ Value::asUInt () const
return value_.bool_ ? 1 : 0;
case stringValue:
return lexicalCastThrow <unsigned int> (value_.string_);
return beast::lexicalCastThrow <unsigned int> (value_.string_);
case arrayValue:
case objectValue:

View File

@@ -0,0 +1,33 @@
//------------------------------------------------------------------------------
/*
Copyright (c) 2011-2013, OpenCoin, Inc.
*/
//==============================================================================
#include "BeastConfig.h"
#include "beast/modules/beast_core/beast_core.h"
#include "ripple_json.h"
#include <cassert>
#include <iomanip>
#include <sstream>
#include <string>
// For json/
//
#ifdef JSON_USE_CPPTL
# include <cpptl/conststring.h>
#endif
#ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
#include "impl/json_batchallocator.h"
#endif
#define JSON_ASSERT_UNREACHABLE assert( false )
#define JSON_ASSERT( condition ) assert( condition ); // @todo <= change this into an exception throw
#define JSON_ASSERT_MESSAGE( condition, message ) if (!( condition )) throw std::runtime_error( message );
#include "impl/json_reader.cpp"
#include "impl/json_value.cpp"
#include "impl/json_writer.cpp"

View File

@@ -0,0 +1,35 @@
//------------------------------------------------------------------------------
/*
Copyright (c) 2011-2013, OpenCoin, Inc.
*/
//==============================================================================
#ifndef RIPPLE_JSON_H_INCLUDED
#define RIPPLE_JSON_H_INCLUDED
#include "beast/beast/Config.h"
#include <deque>
#include <stack>
#include <vector>
// For json/
//
// VFALCO TODO Clean up these one-offs
#include "api/json_config.h" // Needed before these cpptl includes
#ifndef JSON_USE_CPPTL_SMALLMAP
# include <map>
#else
# include <cpptl/smallmap.h>
#endif
#ifdef JSON_USE_CPPTL
# include <cpptl/forwards.h>
#endif
#include "api/json_forwards.h"
#include "api/json_features.h"
#include "api/json_value.h"
#include "api/json_reader.h"
#include "api/json_writer.h"
#endif

View File

@@ -31,21 +31,6 @@
//------------------------------------------------------------------------------
// For json/
//
#ifdef JSON_USE_CPPTL
# include <cpptl/conststring.h>
#endif
#ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
#include "json/json_batchallocator.h"
#endif
#define JSON_ASSERT_UNREACHABLE assert( false )
#define JSON_ASSERT( condition ) assert( condition ); // @todo <= change this into an exception throw
#define JSON_ASSERT_MESSAGE( condition, message ) if (!( condition )) throw std::runtime_error( message );
//------------------------------------------------------------------------------
// For random numbers
//
// VFALCO TODO Replace OpenSSL randomness with a dependency-free implementation
@@ -75,10 +60,6 @@ namespace ripple
#include "containers/RangeSet.cpp"
#include "containers/TaggedCache.cpp"
#include "json/json_reader.cpp"
#include "json/json_value.cpp"
#include "json/json_writer.cpp"
#include "log/Log.cpp"
#include "log/LogFile.cpp"
#include "log/LogJournal.cpp"

View File

@@ -24,21 +24,6 @@
//------------------------------------------------------------------------------
// For json/
//
// VFALCO TODO Clean up these one-offs
#include "json/json_config.h" // Needed before these cpptl includes
#ifndef JSON_USE_CPPTL_SMALLMAP
# include <map>
#else
# include <cpptl/smallmap.h>
#endif
#ifdef JSON_USE_CPPTL
# include <cpptl/forwards.h>
#endif
//------------------------------------------------------------------------------
#include "beast/modules/beast_core/system/BeforeBoost.h" // must come first
#include "system/BoostIncludes.h"
@@ -124,12 +109,6 @@ using namespace beast;
#include "containers/SecureAllocator.h"
#include "containers/TaggedCache.h"
#include "json/json_forwards.h"
#include "json/json_features.h"
#include "json/json_value.h"
#include "json/json_reader.h"
#include "json/json_writer.h"
}
#endif

View File

@@ -27,6 +27,8 @@
// additional hierarchy via directories.
#include "ripple.pb.h"
#include "../ripple/json/ripple_json.h"
namespace ripple
{