fix json_rpc_errorobj
This commit is contained in:
parent
9225ab4726
commit
6bf25ae8e7
8 changed files with 38 additions and 15 deletions
|
|
@ -64,6 +64,8 @@ namespace fc {
|
|||
void create_directories( const path& p );
|
||||
path canonical( const path& p );
|
||||
uint64_t file_size( const path& p );
|
||||
bool remove( const path& p );
|
||||
void copy( const path& from, const path& to );
|
||||
}
|
||||
|
||||
#endif // _FC_FILESYSTEM_HPP_
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
#pragma once
|
||||
#include <fc/fwd.hpp>
|
||||
#include <fc/iostream.hpp>
|
||||
|
||||
namespace fc {
|
||||
|
||||
class ofstream //: virtual public ostream {
|
||||
class path;
|
||||
class ofstream : virtual public ostream {
|
||||
public:
|
||||
enum mode { out, binary };
|
||||
ofstream();
|
||||
ofstream( const fc::string& file, int m );
|
||||
ofstream( const fc::path& file, int m = binary );
|
||||
~ofstream();
|
||||
|
||||
void open( const fc::string& file, int m );
|
||||
void open( const fc::path& file, int m = binary );
|
||||
ofstream& write( const char* buf, size_t len );
|
||||
void put( char c );
|
||||
void close();
|
||||
|
|
@ -21,14 +22,14 @@ namespace fc {
|
|||
fwd<impl,896> my;
|
||||
};
|
||||
|
||||
class ifstream //: virtual public istream {
|
||||
class ifstream : virtual public istream {
|
||||
public:
|
||||
enum mode { in, binary };
|
||||
ifstream();
|
||||
ifstream( const fc::string& file, int m );
|
||||
ifstream( const fc::path& file, int m );
|
||||
~ifstream();
|
||||
|
||||
void open( const fc::string& file, int m );
|
||||
void open( const fc::path& file, int m );
|
||||
ifstream& read( char* buf, size_t len );
|
||||
void close();
|
||||
void flush();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
#pragma once
|
||||
#include <fc/string.hpp>
|
||||
#include <fc/optional.hpp>
|
||||
#include <fc/value.hpp>
|
||||
|
||||
namespace fc { namespace json {
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <fc/reflect.hpp>
|
||||
|
||||
namespace fc {
|
||||
class path;
|
||||
|
||||
class sha1 {
|
||||
public:
|
||||
|
|
@ -18,6 +19,7 @@ namespace fc {
|
|||
|
||||
static sha1 hash( const char* d, uint32_t dlen );
|
||||
static sha1 hash( const fc::string& );
|
||||
static sha1 hash( const fc::path& );
|
||||
|
||||
template<typename T>
|
||||
static sha1 hash( const T& t ) { sha1::encoder e; e << t; return e.result(); }
|
||||
|
|
|
|||
|
|
@ -127,6 +127,14 @@ namespace fc {
|
|||
bool is_null()const;
|
||||
|
||||
void visit( const_visitor&& v )const;
|
||||
|
||||
/* sets the subkey key with v and return *this */
|
||||
value& set( const char* key, fc::value v );
|
||||
value& set( const fc::string& key, fc::value v );
|
||||
|
||||
template<typename S, typename T>
|
||||
value& set( S&& key, T&& v ) { return set( fc::forward<S>(key), fc::value( fc::forward<T>(v) ) ); }
|
||||
|
||||
private:
|
||||
/** throws exceptions on errors
|
||||
*
|
||||
|
|
|
|||
|
|
@ -75,4 +75,6 @@ namespace fc {
|
|||
bool is_directory( const path& p ) { return boost::filesystem::is_directory(p); }
|
||||
bool is_regular_file( const path& p ) { return boost::filesystem::is_regular_file(p); }
|
||||
uint64_t file_size( const path& p ) { return boost::filesystem::file_size(p); }
|
||||
void copy( const path& f, const path& t ) { boost::filesystem::copy( f, t ); }
|
||||
void remove( const path& f ) { boost::filesystem::remove( f, t ); }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <fc/json_rpc_error_object.hpp>
|
||||
|
||||
namespace fc { namespace json {
|
||||
error_object::error_object( const fc::string& msg, fc::value v, int c )
|
||||
error_object::error_object( const fc::string& m, fc::value v, int64_t c )
|
||||
:code(c),message(m),data(fc::move(v)){}
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ namespace fc {
|
|||
struct value_holder_impl<void> : value_holder {
|
||||
value_holder_impl(){};
|
||||
// typedef void_t T;
|
||||
/*
|
||||
virtual const char* type()const { return "void"; }
|
||||
virtual void visit( value::const_visitor&& v )const{ v(); }
|
||||
virtual void visit( value_visitor&& v ) { v(); }
|
||||
|
|
@ -56,6 +57,7 @@ namespace fc {
|
|||
|
||||
virtual value_holder* move_helper( char* c ){ return new(c) value_holder_impl(); }
|
||||
virtual value_holder* copy_helper( char* c )const{ return new(c) value_holder_impl();}
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -121,7 +123,10 @@ namespace fc {
|
|||
};
|
||||
|
||||
value_holder::~value_holder(){}
|
||||
const char* value_holder::type()const { return "null"; }
|
||||
const char* value_holder::type()const { return "void"; }
|
||||
value_holder* value_holder::move_helper( char* c ) { return new(c) value_holder(); }
|
||||
value_holder* value_holder::copy_helper( char* c )const { return new(c) value_holder(); }
|
||||
|
||||
void value_holder::visit( value::const_visitor&& v )const { v(); }
|
||||
void value_holder::visit( value_visitor&& v ) { v(); }
|
||||
|
||||
|
|
@ -133,8 +138,8 @@ namespace fc {
|
|||
const value& value_holder::at( size_t )const { FC_THROW_MSG("value type '%s' not an array", type()); return *((const value*)0); }
|
||||
void value_holder::push_back( value&& v ) { FC_THROW_MSG("value type '%s' not an array", type()); }
|
||||
|
||||
value_holder* value_holder::move_helper( char* c ) { return new(c) value_holder(); }
|
||||
value_holder* value_holder::copy_helper( char* c )const{ return new(c) value_holder(); }
|
||||
// value_holder* value_holder::move_helper( char* c ) = 0;
|
||||
// value_holder* value_holder::copy_helper( char* c )const = 0;
|
||||
|
||||
void value_holder_impl<value::array>::resize( size_t s ) { val.fields.resize(s); }
|
||||
void value_holder_impl<value::array>::reserve( size_t s ) { val.fields.reserve(s); }
|
||||
|
|
@ -168,7 +173,7 @@ static const detail::value_holder* gh( const aligned<24>& h ) {
|
|||
}
|
||||
|
||||
value::value() {
|
||||
new (holder) detail::value_holder();
|
||||
new (holder) detail::value_holder_impl<void>();
|
||||
}
|
||||
value::value( value&& m ) {
|
||||
gh(m.holder)->move_helper(holder._store._data);
|
||||
|
|
@ -180,7 +185,7 @@ value::value( char* c ) {
|
|||
new (holder) detail::value_holder_impl<fc::string>( c );
|
||||
}
|
||||
value::~value() {
|
||||
gh(holder)->~value_holder();
|
||||
gh(holder)->~value_holder_impl<void>();
|
||||
}
|
||||
value::value( int8_t v){
|
||||
static_assert( sizeof(holder) >= sizeof( detail::value_holder_impl<int8_t> ), "size check" );
|
||||
|
|
@ -271,7 +276,7 @@ value& value::operator=( const value& v ){
|
|||
return *this;
|
||||
}
|
||||
bool value::is_null()const {
|
||||
return strcmp(gh(holder)->type(), "null") == 0;
|
||||
return strcmp(gh(holder)->type(), "void") == 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -314,7 +319,7 @@ value& value::operator[]( const char* key ) {
|
|||
}
|
||||
o->val.fields.push_back( key_val(key) );
|
||||
return o->val.fields.back().val;
|
||||
} else if (strcmp(gh(holder)->type(), "null" ) == 0 ) {
|
||||
} else if (strcmp(gh(holder)->type(), "void" ) == 0 ) {
|
||||
new (holder) detail::value_holder_impl<value::object>(value::object());
|
||||
return (*this)[key];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue