mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-25 13:35:54 +00:00
Support compiling with C++11 rules. Compile C++11 by default.
This gives us some significant performance boosts when containers and binds.
This commit is contained in:
@@ -100,7 +100,7 @@ BOOSTFLAGS = ['-DBOOST_TEST_DYN_LINK', '-DBOOST_FILESYSTEM_NO_DEPRECATED']
|
|||||||
|
|
||||||
env.Append(LINKFLAGS = ['-rdynamic', '-pthread'])
|
env.Append(LINKFLAGS = ['-rdynamic', '-pthread'])
|
||||||
env.Append(CCFLAGS = ['-pthread', '-Wall', '-Wno-sign-compare', '-Wno-char-subscripts', '-DSQLITE_THREADSAFE=1'])
|
env.Append(CCFLAGS = ['-pthread', '-Wall', '-Wno-sign-compare', '-Wno-char-subscripts', '-DSQLITE_THREADSAFE=1'])
|
||||||
env.Append(CXXFLAGS = ['-O0', '-pthread', '-Wno-invalid-offsetof', '-Wformat']+BOOSTFLAGS+DEBUGFLAGS)
|
env.Append(CXXFLAGS = ['-O0', '-std=c++11', '-pthread', '-Wno-invalid-offsetof', '-Wformat']+BOOSTFLAGS+DEBUGFLAGS)
|
||||||
|
|
||||||
if OSX:
|
if OSX:
|
||||||
env.Append(LINKFLAGS = ['-L/usr/local/opt/openssl/lib'])
|
env.Append(LINKFLAGS = ['-L/usr/local/opt/openssl/lib'])
|
||||||
|
|||||||
@@ -1187,7 +1187,7 @@ STAmount STAmount::getPay(const STAmount& offerOut, const STAmount& offerIn, con
|
|||||||
|
|
||||||
STAmount STAmount::deserialize(SerializerIterator& it)
|
STAmount STAmount::deserialize(SerializerIterator& it)
|
||||||
{
|
{
|
||||||
std::auto_ptr<STAmount> s(dynamic_cast<STAmount*>(construct(it, sfGeneric)));
|
UPTR_T<STAmount> s(dynamic_cast<STAmount*>(construct(it, sfGeneric)));
|
||||||
STAmount ret(*s);
|
STAmount ret(*s);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ HashedObject::pointer HashedObjectStore::retrieve(const uint256& hash)
|
|||||||
int HashedObjectStore::import(const std::string& file)
|
int HashedObjectStore::import(const std::string& file)
|
||||||
{
|
{
|
||||||
cLog(lsWARNING) << "Hash import from \"" << file << "\".";
|
cLog(lsWARNING) << "Hash import from \"" << file << "\".";
|
||||||
std::auto_ptr<Database> importDB(new SqliteDatabase(file.c_str()));
|
UPTR_T<Database> importDB(new SqliteDatabase(file.c_str()));
|
||||||
importDB->connect();
|
importDB->connect();
|
||||||
|
|
||||||
int countYes = 0, countNo = 0;
|
int countYes = 0, countNo = 0;
|
||||||
|
|||||||
@@ -6,7 +6,9 @@
|
|||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
extern int upTime();
|
extern int upTime();
|
||||||
|
|
||||||
// Monitors load levels and response times
|
// Monitors load levels and response times
|
||||||
@@ -54,7 +56,7 @@ class LoadEvent
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef boost::shared_ptr<LoadEvent> pointer;
|
typedef boost::shared_ptr<LoadEvent> pointer;
|
||||||
typedef std::auto_ptr<LoadEvent> autoptr;
|
typedef UPTR_T<LoadEvent> autoptr;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LoadMonitor& mMonitor;
|
LoadMonitor& mMonitor;
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ Json::Value RPCHandler::transactionSign(Json::Value jvRequest, bool bSubmit)
|
|||||||
return rpcError(rpcSRC_ACT_NOT_FOUND);
|
return rpcError(rpcSRC_ACT_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::auto_ptr<STObject> sopTrans;
|
UPTR_T<STObject> sopTrans;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,56 +17,56 @@ SETUP_LOG();
|
|||||||
DECLARE_INSTANCE(SerializedObject);
|
DECLARE_INSTANCE(SerializedObject);
|
||||||
DECLARE_INSTANCE(SerializedArray);
|
DECLARE_INSTANCE(SerializedArray);
|
||||||
|
|
||||||
std::auto_ptr<SerializedType> STObject::makeDefaultObject(SerializedTypeID id, SField::ref name)
|
UPTR_T<SerializedType> STObject::makeDefaultObject(SerializedTypeID id, SField::ref name)
|
||||||
{
|
{
|
||||||
assert((id == STI_NOTPRESENT) || (id == name.fieldType));
|
assert((id == STI_NOTPRESENT) || (id == name.fieldType));
|
||||||
|
|
||||||
switch(id)
|
switch(id)
|
||||||
{
|
{
|
||||||
case STI_NOTPRESENT:
|
case STI_NOTPRESENT:
|
||||||
return std::auto_ptr<SerializedType>(new SerializedType(name));
|
return UPTR_T<SerializedType>(new SerializedType(name));
|
||||||
|
|
||||||
case STI_UINT8:
|
case STI_UINT8:
|
||||||
return std::auto_ptr<SerializedType>(new STUInt8(name));
|
return UPTR_T<SerializedType>(new STUInt8(name));
|
||||||
|
|
||||||
case STI_UINT16:
|
case STI_UINT16:
|
||||||
return std::auto_ptr<SerializedType>(new STUInt16(name));
|
return UPTR_T<SerializedType>(new STUInt16(name));
|
||||||
|
|
||||||
case STI_UINT32:
|
case STI_UINT32:
|
||||||
return std::auto_ptr<SerializedType>(new STUInt32(name));
|
return UPTR_T<SerializedType>(new STUInt32(name));
|
||||||
|
|
||||||
case STI_UINT64:
|
case STI_UINT64:
|
||||||
return std::auto_ptr<SerializedType>(new STUInt64(name));
|
return UPTR_T<SerializedType>(new STUInt64(name));
|
||||||
|
|
||||||
case STI_AMOUNT:
|
case STI_AMOUNT:
|
||||||
return std::auto_ptr<SerializedType>(new STAmount(name));
|
return UPTR_T<SerializedType>(new STAmount(name));
|
||||||
|
|
||||||
case STI_HASH128:
|
case STI_HASH128:
|
||||||
return std::auto_ptr<SerializedType>(new STHash128(name));
|
return UPTR_T<SerializedType>(new STHash128(name));
|
||||||
|
|
||||||
case STI_HASH160:
|
case STI_HASH160:
|
||||||
return std::auto_ptr<SerializedType>(new STHash160(name));
|
return UPTR_T<SerializedType>(new STHash160(name));
|
||||||
|
|
||||||
case STI_HASH256:
|
case STI_HASH256:
|
||||||
return std::auto_ptr<SerializedType>(new STHash256(name));
|
return UPTR_T<SerializedType>(new STHash256(name));
|
||||||
|
|
||||||
case STI_VECTOR256:
|
case STI_VECTOR256:
|
||||||
return std::auto_ptr<SerializedType>(new STVector256(name));
|
return UPTR_T<SerializedType>(new STVector256(name));
|
||||||
|
|
||||||
case STI_VL:
|
case STI_VL:
|
||||||
return std::auto_ptr<SerializedType>(new STVariableLength(name));
|
return UPTR_T<SerializedType>(new STVariableLength(name));
|
||||||
|
|
||||||
case STI_ACCOUNT:
|
case STI_ACCOUNT:
|
||||||
return std::auto_ptr<SerializedType>(new STAccount(name));
|
return UPTR_T<SerializedType>(new STAccount(name));
|
||||||
|
|
||||||
case STI_PATHSET:
|
case STI_PATHSET:
|
||||||
return std::auto_ptr<SerializedType>(new STPathSet(name));
|
return UPTR_T<SerializedType>(new STPathSet(name));
|
||||||
|
|
||||||
case STI_OBJECT:
|
case STI_OBJECT:
|
||||||
return std::auto_ptr<SerializedType>(new STObject(name));
|
return UPTR_T<SerializedType>(new STObject(name));
|
||||||
|
|
||||||
case STI_ARRAY:
|
case STI_ARRAY:
|
||||||
return std::auto_ptr<SerializedType>(new STArray(name));
|
return UPTR_T<SerializedType>(new STArray(name));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
cLog(lsFATAL) << "Object type: " << lexical_cast_i(id);
|
cLog(lsFATAL) << "Object type: " << lexical_cast_i(id);
|
||||||
@@ -75,7 +75,7 @@ std::auto_ptr<SerializedType> STObject::makeDefaultObject(SerializedTypeID id, S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::auto_ptr<SerializedType> STObject::makeDeserializedObject(SerializedTypeID id, SField::ref name,
|
UPTR_T<SerializedType> STObject::makeDeserializedObject(SerializedTypeID id, SField::ref name,
|
||||||
SerializerIterator& sit, int depth)
|
SerializerIterator& sit, int depth)
|
||||||
{
|
{
|
||||||
switch(id)
|
switch(id)
|
||||||
@@ -192,7 +192,7 @@ bool STObject::setType(const SOTemplate &type)
|
|||||||
<< elem->e_field.fieldName;
|
<< elem->e_field.fieldName;
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
newData.push_back(makeNonPresentObject(elem->e_field));
|
newData.push_back(makeNonPresentObject(elem->e_field).release());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,10 +252,10 @@ bool STObject::set(SerializerIterator& sit, int depth)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::auto_ptr<SerializedType> STObject::deserialize(SerializerIterator& sit, SField::ref name)
|
UPTR_T<SerializedType> STObject::deserialize(SerializerIterator& sit, SField::ref name)
|
||||||
{
|
{
|
||||||
STObject *o;
|
STObject *o;
|
||||||
std::auto_ptr<SerializedType> object(o = new STObject(name));
|
UPTR_T<SerializedType> object(o = new STObject(name));
|
||||||
o->set(sit, 1);
|
o->set(sit, 1);
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
@@ -482,7 +482,7 @@ SerializedType* STObject::makeFieldPresent(SField::ref field)
|
|||||||
SerializedType* f = getPIndex(index);
|
SerializedType* f = getPIndex(index);
|
||||||
if (f->getSType() != STI_NOTPRESENT)
|
if (f->getSType() != STI_NOTPRESENT)
|
||||||
return f;
|
return f;
|
||||||
mData.replace(index, makeDefaultObject(f->getFName()));
|
mData.replace(index, makeDefaultObject(f->getFName()).release());
|
||||||
return getPIndex(index);
|
return getPIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -496,7 +496,7 @@ void STObject::makeFieldAbsent(SField::ref field)
|
|||||||
if (f.getSType() == STI_NOTPRESENT)
|
if (f.getSType() == STI_NOTPRESENT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mData.replace(index, makeNonPresentObject(f.getFName()));
|
mData.replace(index, makeNonPresentObject(f.getFName()).release());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool STObject::delField(SField::ref field)
|
bool STObject::delField(SField::ref field)
|
||||||
@@ -957,7 +957,7 @@ void STArray::sort(bool (*compare)(const STObject&, const STObject&))
|
|||||||
value.sort(compare);
|
value.sort(compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::auto_ptr<STObject> STObject::parseJson(const Json::Value& object, SField::ref inName, int depth)
|
UPTR_T<STObject> STObject::parseJson(const Json::Value& object, SField::ref inName, int depth)
|
||||||
{
|
{
|
||||||
if (!object.isObject())
|
if (!object.isObject())
|
||||||
throw std::runtime_error("Value is not an object");
|
throw std::runtime_error("Value is not an object");
|
||||||
@@ -1219,7 +1219,7 @@ std::auto_ptr<STObject> STObject::parseJson(const Json::Value& object, SField::r
|
|||||||
throw std::runtime_error("Inner value is not an object");
|
throw std::runtime_error("Inner value is not an object");
|
||||||
if (depth > 64)
|
if (depth > 64)
|
||||||
throw std::runtime_error("Json nest depth exceeded");
|
throw std::runtime_error("Json nest depth exceeded");
|
||||||
data.push_back(parseJson(value, field, depth + 1));
|
data.push_back(parseJson(value, field, depth + 1).release());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STI_ARRAY:
|
case STI_ARRAY:
|
||||||
@@ -1238,7 +1238,7 @@ std::auto_ptr<STObject> STObject::parseJson(const Json::Value& object, SField::r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::auto_ptr<STObject>(new STObject(*name, data));
|
return UPTR_T<STObject>(new STObject(*name, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(SerializedObject)
|
BOOST_AUTO_TEST_SUITE(SerializedObject)
|
||||||
|
|||||||
@@ -58,13 +58,13 @@ public:
|
|||||||
STObject(const SOTemplate& type, SerializerIterator& sit, SField::ref name) : SerializedType(name)
|
STObject(const SOTemplate& type, SerializerIterator& sit, SField::ref name) : SerializedType(name)
|
||||||
{ set(sit); setType(type); }
|
{ set(sit); setType(type); }
|
||||||
|
|
||||||
std::auto_ptr<STObject> oClone() const { return std::auto_ptr<STObject>(new STObject(*this)); }
|
UPTR_T<STObject> oClone() const { return UPTR_T<STObject>(new STObject(*this)); }
|
||||||
|
|
||||||
static std::auto_ptr<STObject> parseJson(const Json::Value& value, SField::ref name = sfGeneric, int depth = 0);
|
static UPTR_T<STObject> parseJson(const Json::Value& value, SField::ref name = sfGeneric, int depth = 0);
|
||||||
|
|
||||||
virtual ~STObject() { ; }
|
virtual ~STObject() { ; }
|
||||||
|
|
||||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name);
|
static UPTR_T<SerializedType> deserialize(SerializerIterator& sit, SField::ref name);
|
||||||
|
|
||||||
bool setType(const SOTemplate& type);
|
bool setType(const SOTemplate& type);
|
||||||
bool isValidForType();
|
bool isValidForType();
|
||||||
@@ -85,8 +85,8 @@ public:
|
|||||||
std::string getText() const;
|
std::string getText() const;
|
||||||
virtual Json::Value getJson(int options) const;
|
virtual Json::Value getJson(int options) const;
|
||||||
|
|
||||||
int addObject(const SerializedType& t) { mData.push_back(t.clone()); return mData.size() - 1; }
|
int addObject(const SerializedType& t) { mData.push_back(t.clone().release()); return mData.size() - 1; }
|
||||||
int giveObject(std::auto_ptr<SerializedType> t) { mData.push_back(t); return mData.size() - 1; }
|
int giveObject(UPTR_T<SerializedType> t) { mData.push_back(t.release()); return mData.size() - 1; }
|
||||||
int giveObject(SerializedType* t) { mData.push_back(t); return mData.size() - 1; }
|
int giveObject(SerializedType* t) { mData.push_back(t); return mData.size() - 1; }
|
||||||
const boost::ptr_vector<SerializedType>& peekData() const { return mData; }
|
const boost::ptr_vector<SerializedType>& peekData() const { return mData; }
|
||||||
boost::ptr_vector<SerializedType>& peekData() { return mData; }
|
boost::ptr_vector<SerializedType>& peekData() { return mData; }
|
||||||
@@ -157,13 +157,13 @@ public:
|
|||||||
bool delField(SField::ref field);
|
bool delField(SField::ref field);
|
||||||
void delField(int index);
|
void delField(int index);
|
||||||
|
|
||||||
static std::auto_ptr<SerializedType> makeDefaultObject(SerializedTypeID id, SField::ref name);
|
static UPTR_T<SerializedType> makeDefaultObject(SerializedTypeID id, SField::ref name);
|
||||||
static std::auto_ptr<SerializedType> makeDeserializedObject(SerializedTypeID id, SField::ref name,
|
static UPTR_T<SerializedType> makeDeserializedObject(SerializedTypeID id, SField::ref name,
|
||||||
SerializerIterator&, int depth);
|
SerializerIterator&, int depth);
|
||||||
|
|
||||||
static std::auto_ptr<SerializedType> makeNonPresentObject(SField::ref name)
|
static UPTR_T<SerializedType> makeNonPresentObject(SField::ref name)
|
||||||
{ return makeDefaultObject(STI_NOTPRESENT, name); }
|
{ return makeDefaultObject(STI_NOTPRESENT, name); }
|
||||||
static std::auto_ptr<SerializedType> makeDefaultObject(SField::ref name)
|
static UPTR_T<SerializedType> makeDefaultObject(SField::ref name)
|
||||||
{ return makeDefaultObject(name.fieldType, name); }
|
{ return makeDefaultObject(name.fieldType, name); }
|
||||||
|
|
||||||
// field iterator stuff
|
// field iterator stuff
|
||||||
@@ -221,14 +221,14 @@ public:
|
|||||||
STArray(SField::ref f, const vector& v) : SerializedType(f), value(v) { ; }
|
STArray(SField::ref f, const vector& v) : SerializedType(f), value(v) { ; }
|
||||||
STArray(vector& v) : value(v) { ; }
|
STArray(vector& v) : value(v) { ; }
|
||||||
|
|
||||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
static UPTR_T<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
{ return UPTR_T<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
const vector& getValue() const { return value; }
|
const vector& getValue() const { return value; }
|
||||||
vector& getValue() { return value; }
|
vector& getValue() { return value; }
|
||||||
|
|
||||||
// vector-like functions
|
// vector-like functions
|
||||||
void push_back(const STObject& object) { value.push_back(object.oClone()); }
|
void push_back(const STObject& object) { value.push_back(object.oClone().release()); }
|
||||||
STObject& operator[](int j) { return value[j]; }
|
STObject& operator[](int j) { return value[j]; }
|
||||||
const STObject& operator[](int j) const { return value[j]; }
|
const STObject& operator[](int j) const { return value[j]; }
|
||||||
iterator begin() { return value.begin(); }
|
iterator begin() { return value.begin(); }
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ BOOST_AUTO_TEST_CASE( STrans_test )
|
|||||||
Log(lsFATAL) << copy.getJson(0);
|
Log(lsFATAL) << copy.getJson(0);
|
||||||
BOOST_FAIL("Transaction fails serialize/deserialize test");
|
BOOST_FAIL("Transaction fails serialize/deserialize test");
|
||||||
}
|
}
|
||||||
std::auto_ptr<STObject> new_obj = STObject::parseJson(j.getJson(0), sfGeneric);
|
UPTR_T<STObject> new_obj = STObject::parseJson(j.getJson(0), sfGeneric);
|
||||||
if (new_obj.get() == NULL) BOOST_FAIL("Unable to build object from json");
|
if (new_obj.get() == NULL) BOOST_FAIL("Unable to build object from json");
|
||||||
|
|
||||||
if (STObject(j) != *new_obj)
|
if (STObject(j) != *new_obj)
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ STVector256* STVector256::construct(SerializerIterator& u, SField::ref name)
|
|||||||
{
|
{
|
||||||
std::vector<unsigned char> data = u.getVL();
|
std::vector<unsigned char> data = u.getVL();
|
||||||
|
|
||||||
std::auto_ptr<STVector256> vec(new STVector256(name));
|
UPTR_T<STVector256> vec(new STVector256(name));
|
||||||
|
|
||||||
int count = data.size() / (256 / 8);
|
int count = data.size() / (256 / 8);
|
||||||
vec->mValue.reserve(count);
|
vec->mValue.reserve(count);
|
||||||
|
|||||||
@@ -58,15 +58,15 @@ public:
|
|||||||
SerializedType(SField::ref n) : fName(&n) { assert(fName); }
|
SerializedType(SField::ref n) : fName(&n) { assert(fName); }
|
||||||
virtual ~SerializedType() { ; }
|
virtual ~SerializedType() { ; }
|
||||||
|
|
||||||
static std::auto_ptr<SerializedType> deserialize(SField::ref name)
|
static UPTR_T<SerializedType> deserialize(SField::ref name)
|
||||||
{ return std::auto_ptr<SerializedType>(new SerializedType(name)); }
|
{ return UPTR_T<SerializedType>(new SerializedType(name)); }
|
||||||
|
|
||||||
void setFName(SField::ref n) { fName = &n; assert(fName); }
|
void setFName(SField::ref n) { fName = &n; assert(fName); }
|
||||||
SField::ref getFName() const { return *fName; }
|
SField::ref getFName() const { return *fName; }
|
||||||
std::string getName() const { return fName->fieldName; }
|
std::string getName() const { return fName->fieldName; }
|
||||||
|
|
||||||
virtual SerializedTypeID getSType() const { return STI_NOTPRESENT; }
|
virtual SerializedTypeID getSType() const { return STI_NOTPRESENT; }
|
||||||
std::auto_ptr<SerializedType> clone() const { return std::auto_ptr<SerializedType>(duplicate()); }
|
UPTR_T<SerializedType> clone() const { return UPTR_T<SerializedType>(duplicate()); }
|
||||||
|
|
||||||
virtual std::string getFullText() const;
|
virtual std::string getFullText() const;
|
||||||
virtual std::string getText() const // just the value
|
virtual std::string getText() const // just the value
|
||||||
@@ -107,8 +107,8 @@ public:
|
|||||||
|
|
||||||
STUInt8(unsigned char v = 0) : value(v) { ; }
|
STUInt8(unsigned char v = 0) : value(v) { ; }
|
||||||
STUInt8(SField::ref n, unsigned char v = 0) : SerializedType(n), value(v) { ; }
|
STUInt8(SField::ref n, unsigned char v = 0) : SerializedType(n), value(v) { ; }
|
||||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
static UPTR_T<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
{ return UPTR_T<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
SerializedTypeID getSType() const { return STI_UINT8; }
|
SerializedTypeID getSType() const { return STI_UINT8; }
|
||||||
std::string getText() const;
|
std::string getText() const;
|
||||||
@@ -135,8 +135,8 @@ public:
|
|||||||
|
|
||||||
STUInt16(uint16 v = 0) : value(v) { ; }
|
STUInt16(uint16 v = 0) : value(v) { ; }
|
||||||
STUInt16(SField::ref n, uint16 v = 0) : SerializedType(n), value(v) { ; }
|
STUInt16(SField::ref n, uint16 v = 0) : SerializedType(n), value(v) { ; }
|
||||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
static UPTR_T<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
{ return UPTR_T<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
SerializedTypeID getSType() const { return STI_UINT16; }
|
SerializedTypeID getSType() const { return STI_UINT16; }
|
||||||
std::string getText() const;
|
std::string getText() const;
|
||||||
@@ -163,8 +163,8 @@ public:
|
|||||||
|
|
||||||
STUInt32(uint32 v = 0) : value(v) { ; }
|
STUInt32(uint32 v = 0) : value(v) { ; }
|
||||||
STUInt32(SField::ref n, uint32 v = 0) : SerializedType(n), value(v) { ; }
|
STUInt32(SField::ref n, uint32 v = 0) : SerializedType(n), value(v) { ; }
|
||||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
static UPTR_T<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
{ return UPTR_T<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
SerializedTypeID getSType() const { return STI_UINT32; }
|
SerializedTypeID getSType() const { return STI_UINT32; }
|
||||||
std::string getText() const;
|
std::string getText() const;
|
||||||
@@ -191,8 +191,8 @@ public:
|
|||||||
|
|
||||||
STUInt64(uint64 v = 0) : value(v) { ; }
|
STUInt64(uint64 v = 0) : value(v) { ; }
|
||||||
STUInt64(SField::ref n, uint64 v = 0) : SerializedType(n), value(v) { ; }
|
STUInt64(SField::ref n, uint64 v = 0) : SerializedType(n), value(v) { ; }
|
||||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
static UPTR_T<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
{ return UPTR_T<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
SerializedTypeID getSType() const { return STI_UINT64; }
|
SerializedTypeID getSType() const { return STI_UINT64; }
|
||||||
std::string getText() const;
|
std::string getText() const;
|
||||||
@@ -331,8 +331,8 @@ public:
|
|||||||
|
|
||||||
static STAmount createFromInt64(SField::ref n, int64 v);
|
static STAmount createFromInt64(SField::ref n, int64 v);
|
||||||
|
|
||||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
static UPTR_T<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
{ return UPTR_T<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
bool bSetJson(const Json::Value& jvSource);
|
bool bSetJson(const Json::Value& jvSource);
|
||||||
|
|
||||||
@@ -493,8 +493,8 @@ public:
|
|||||||
STHash128(SField::ref n, const std::string &v) : SerializedType(n) { value.SetHex(v); }
|
STHash128(SField::ref n, const std::string &v) : SerializedType(n) { value.SetHex(v); }
|
||||||
STHash128(SField::ref n) : SerializedType(n) { ; }
|
STHash128(SField::ref n) : SerializedType(n) { ; }
|
||||||
STHash128() { ; }
|
STHash128() { ; }
|
||||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
static UPTR_T<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
{ return UPTR_T<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
SerializedTypeID getSType() const { return STI_HASH128; }
|
SerializedTypeID getSType() const { return STI_HASH128; }
|
||||||
virtual std::string getText() const;
|
virtual std::string getText() const;
|
||||||
@@ -524,8 +524,8 @@ public:
|
|||||||
STHash160(SField::ref n, const std::string &v) : SerializedType(n) { value.SetHex(v); }
|
STHash160(SField::ref n, const std::string &v) : SerializedType(n) { value.SetHex(v); }
|
||||||
STHash160(SField::ref n) : SerializedType(n) { ; }
|
STHash160(SField::ref n) : SerializedType(n) { ; }
|
||||||
STHash160() { ; }
|
STHash160() { ; }
|
||||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
static UPTR_T<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
{ return UPTR_T<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
SerializedTypeID getSType() const { return STI_HASH160; }
|
SerializedTypeID getSType() const { return STI_HASH160; }
|
||||||
virtual std::string getText() const;
|
virtual std::string getText() const;
|
||||||
@@ -555,8 +555,8 @@ public:
|
|||||||
STHash256(SField::ref n, const std::string &v) : SerializedType(n) { value.SetHex(v); }
|
STHash256(SField::ref n, const std::string &v) : SerializedType(n) { value.SetHex(v); }
|
||||||
STHash256(SField::ref n) : SerializedType(n) { ; }
|
STHash256(SField::ref n) : SerializedType(n) { ; }
|
||||||
STHash256() { ; }
|
STHash256() { ; }
|
||||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
static UPTR_T<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
{ return UPTR_T<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
SerializedTypeID getSType() const { return STI_HASH256; }
|
SerializedTypeID getSType() const { return STI_HASH256; }
|
||||||
std::string getText() const;
|
std::string getText() const;
|
||||||
@@ -585,8 +585,8 @@ public:
|
|||||||
STVariableLength(SField::ref n) : SerializedType(n) { ; }
|
STVariableLength(SField::ref n) : SerializedType(n) { ; }
|
||||||
STVariableLength(SerializerIterator&, SField::ref name = sfGeneric);
|
STVariableLength(SerializerIterator&, SField::ref name = sfGeneric);
|
||||||
STVariableLength() { ; }
|
STVariableLength() { ; }
|
||||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
static UPTR_T<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
{ return UPTR_T<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
virtual SerializedTypeID getSType() const { return STI_VL; }
|
virtual SerializedTypeID getSType() const { return STI_VL; }
|
||||||
virtual std::string getText() const;
|
virtual std::string getText() const;
|
||||||
@@ -615,8 +615,8 @@ public:
|
|||||||
STAccount(SField::ref n, const uint160& v);
|
STAccount(SField::ref n, const uint160& v);
|
||||||
STAccount(SField::ref n) : STVariableLength(n) { ; }
|
STAccount(SField::ref n) : STVariableLength(n) { ; }
|
||||||
STAccount() { ; }
|
STAccount() { ; }
|
||||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
static UPTR_T<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
{ return UPTR_T<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
SerializedTypeID getSType() const { return STI_ACCOUNT; }
|
SerializedTypeID getSType() const { return STI_ACCOUNT; }
|
||||||
std::string getText() const;
|
std::string getText() const;
|
||||||
@@ -770,8 +770,8 @@ public:
|
|||||||
STPathSet(SField::ref n) : SerializedType(n) { ; }
|
STPathSet(SField::ref n) : SerializedType(n) { ; }
|
||||||
STPathSet(const std::vector<STPath>& v) : value(v) { ; }
|
STPathSet(const std::vector<STPath>& v) : value(v) { ; }
|
||||||
STPathSet(SField::ref n, const std::vector<STPath>& v) : SerializedType(n), value(v) { ; }
|
STPathSet(SField::ref n, const std::vector<STPath>& v) : SerializedType(n), value(v) { ; }
|
||||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
static UPTR_T<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
{ return UPTR_T<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
// std::string getText() const;
|
// std::string getText() const;
|
||||||
void add(Serializer& s) const;
|
void add(Serializer& s) const;
|
||||||
@@ -848,8 +848,8 @@ public:
|
|||||||
SerializedTypeID getSType() const { return STI_VECTOR256; }
|
SerializedTypeID getSType() const { return STI_VECTOR256; }
|
||||||
void add(Serializer& s) const;
|
void add(Serializer& s) const;
|
||||||
|
|
||||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
static UPTR_T<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
{ return UPTR_T<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
const std::vector<uint256>& peekValue() const { return mValue; }
|
const std::vector<uint256>& peekValue() const { return mValue; }
|
||||||
std::vector<uint256>& peekValue() { return mValue; }
|
std::vector<uint256>& peekValue() { return mValue; }
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn, Transa
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::auto_ptr<Transactor> transactor = Transactor::makeTransactor(txn,params,this);
|
UPTR_T<Transactor> transactor = Transactor::makeTransactor(txn,params,this);
|
||||||
if (transactor.get() != NULL)
|
if (transactor.get() != NULL)
|
||||||
{
|
{
|
||||||
uint256 txID = txn.getTransactionID();
|
uint256 txID = txn.getTransactionID();
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ TransactionMetaSet::TransactionMetaSet(const uint256& txid, uint32 ledger, const
|
|||||||
Serializer s(vec);
|
Serializer s(vec);
|
||||||
SerializerIterator sit(s);
|
SerializerIterator sit(s);
|
||||||
|
|
||||||
std::auto_ptr<SerializedType> pobj = STObject::deserialize(sit, sfAffectedNodes);
|
UPTR_T<SerializedType> pobj = STObject::deserialize(sit, sfAffectedNodes);
|
||||||
STObject *obj = static_cast<STObject*>(pobj.get());
|
STObject *obj = static_cast<STObject*>(pobj.get());
|
||||||
if (!obj)
|
if (!obj)
|
||||||
throw std::runtime_error("bad metadata");
|
throw std::runtime_error("bad metadata");
|
||||||
|
|||||||
@@ -11,26 +11,26 @@
|
|||||||
|
|
||||||
SETUP_LOG();
|
SETUP_LOG();
|
||||||
|
|
||||||
std::auto_ptr<Transactor> Transactor::makeTransactor(const SerializedTransaction& txn,TransactionEngineParams params, TransactionEngine* engine)
|
UPTR_T<Transactor> Transactor::makeTransactor(const SerializedTransaction& txn,TransactionEngineParams params, TransactionEngine* engine)
|
||||||
{
|
{
|
||||||
switch(txn.getTxnType())
|
switch(txn.getTxnType())
|
||||||
{
|
{
|
||||||
case ttPAYMENT:
|
case ttPAYMENT:
|
||||||
return std::auto_ptr<Transactor>(new PaymentTransactor(txn, params, engine));
|
return UPTR_T<Transactor>(new PaymentTransactor(txn, params, engine));
|
||||||
case ttACCOUNT_SET:
|
case ttACCOUNT_SET:
|
||||||
return std::auto_ptr<Transactor>(new AccountSetTransactor(txn, params, engine));
|
return UPTR_T<Transactor>(new AccountSetTransactor(txn, params, engine));
|
||||||
case ttREGULAR_KEY_SET:
|
case ttREGULAR_KEY_SET:
|
||||||
return std::auto_ptr<Transactor>(new RegularKeySetTransactor(txn, params, engine));
|
return UPTR_T<Transactor>(new RegularKeySetTransactor(txn, params, engine));
|
||||||
case ttTRUST_SET:
|
case ttTRUST_SET:
|
||||||
return std::auto_ptr<Transactor>(new TrustSetTransactor(txn, params, engine));
|
return UPTR_T<Transactor>(new TrustSetTransactor(txn, params, engine));
|
||||||
case ttOFFER_CREATE:
|
case ttOFFER_CREATE:
|
||||||
return std::auto_ptr<Transactor>(new OfferCreateTransactor(txn, params, engine));
|
return UPTR_T<Transactor>(new OfferCreateTransactor(txn, params, engine));
|
||||||
case ttOFFER_CANCEL:
|
case ttOFFER_CANCEL:
|
||||||
return std::auto_ptr<Transactor>(new OfferCancelTransactor(txn, params, engine));
|
return UPTR_T<Transactor>(new OfferCancelTransactor(txn, params, engine));
|
||||||
case ttWALLET_ADD:
|
case ttWALLET_ADD:
|
||||||
return std::auto_ptr<Transactor>(new WalletAddTransactor(txn, params, engine));
|
return UPTR_T<Transactor>(new WalletAddTransactor(txn, params, engine));
|
||||||
default:
|
default:
|
||||||
return std::auto_ptr<Transactor>();
|
return UPTR_T<Transactor>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#ifndef __TRANSACTOR__
|
#ifndef __TRANSACTOR__
|
||||||
#define __TRANSACTOR__
|
#define __TRANSACTOR__
|
||||||
|
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#include "SerializedTransaction.h"
|
#include "SerializedTransaction.h"
|
||||||
#include "TransactionErr.h"
|
#include "TransactionErr.h"
|
||||||
#include "TransactionEngine.h"
|
#include "TransactionEngine.h"
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
|
|
||||||
class Transactor
|
class Transactor
|
||||||
{
|
{
|
||||||
@@ -38,7 +39,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
typedef boost::shared_ptr<Transactor> pointer;
|
typedef boost::shared_ptr<Transactor> pointer;
|
||||||
|
|
||||||
static std::auto_ptr<Transactor> makeTransactor(const SerializedTransaction& txn,TransactionEngineParams params, TransactionEngine* engine);
|
static UPTR_T<Transactor> makeTransactor(const SerializedTransaction& txn,TransactionEngineParams params, TransactionEngine* engine);
|
||||||
|
|
||||||
TER apply();
|
TER apply();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -286,6 +286,19 @@ template<typename T, typename U> T range_check_cast(const U& value, const T& min
|
|||||||
|
|
||||||
bool parseUrl(const std::string& strUrl, std::string& strScheme, std::string& strDomain, int& iPort, std::string& strPath);
|
bool parseUrl(const std::string& strUrl, std::string& strScheme, std::string& strDomain, int& iPort, std::string& strPath);
|
||||||
|
|
||||||
|
#if (!defined(FORCE_NO_C11X) && (__cplusplus > 201100L)) || defined(FORCE_C11X)
|
||||||
|
|
||||||
|
#define C11X
|
||||||
|
#define UPTR_T std::unique_ptr
|
||||||
|
#define MOVE_P(p) std::move(p)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define UPTR_T std::auto_ptr
|
||||||
|
#define MOVE_P(p) (p)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// vim:ts=4
|
// vim:ts=4
|
||||||
|
|||||||
Reference in New Issue
Block a user