mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Get rid of some ugliness in the use of ptr_vectors. I hope I didn't break anything.
This commit is contained in:
@@ -17,6 +17,8 @@ protected:
|
|||||||
STObject mObject;
|
STObject mObject;
|
||||||
LedgerEntryFormat* mFormat;
|
LedgerEntryFormat* mFormat;
|
||||||
|
|
||||||
|
SerializedLedgerEntry* duplicate() const { return new SerializedLedgerEntry(*this); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SerializedLedgerEntry(const Serializer& s, const uint256& index);
|
SerializedLedgerEntry(const Serializer& s, const uint256& index);
|
||||||
SerializedLedgerEntry(SerializerIterator& sit, const uint256& index);
|
SerializedLedgerEntry(SerializerIterator& sit, const uint256& index);
|
||||||
@@ -24,7 +26,6 @@ public:
|
|||||||
|
|
||||||
int getLength() const { return mVersion.getLength() + mObject.getLength(); }
|
int getLength() const { return mVersion.getLength() + mObject.getLength(); }
|
||||||
SerializedTypeID getSType() const { return STI_LEDGERENTRY; }
|
SerializedTypeID getSType() const { return STI_LEDGERENTRY; }
|
||||||
SerializedLedgerEntry* duplicate() const { return new SerializedLedgerEntry(*this); }
|
|
||||||
std::string getFullText() const;
|
std::string getFullText() const;
|
||||||
std::string getText() const;
|
std::string getText() const;
|
||||||
Json::Value getJson(int options) const;
|
Json::Value getJson(int options) const;
|
||||||
|
|||||||
@@ -5,77 +5,88 @@
|
|||||||
|
|
||||||
#include "../json/writer.h"
|
#include "../json/writer.h"
|
||||||
|
|
||||||
SerializedType* STObject::makeDefaultObject(SerializedTypeID id, const char *name)
|
std::auto_ptr<SerializedType> STObject::makeDefaultObject(SerializedTypeID id, const char *name)
|
||||||
{
|
{
|
||||||
switch(id)
|
switch(id)
|
||||||
{
|
{
|
||||||
|
case STI_NOTPRESENT:
|
||||||
|
return std::auto_ptr<SerializedType>(new SerializedType(name));
|
||||||
|
|
||||||
case STI_UINT16:
|
case STI_UINT16:
|
||||||
return new STUInt16(name);
|
return std::auto_ptr<SerializedType>(new STUInt16(name));
|
||||||
|
|
||||||
case STI_UINT32:
|
case STI_UINT32:
|
||||||
return new STUInt32(name);
|
return std::auto_ptr<SerializedType>(new STUInt32(name));
|
||||||
|
|
||||||
case STI_UINT64:
|
case STI_UINT64:
|
||||||
return new STUInt64(name);
|
return std::auto_ptr<SerializedType>(new STUInt64(name));
|
||||||
|
|
||||||
case STI_AMOUNT:
|
case STI_AMOUNT:
|
||||||
return new STAmount(name);
|
return std::auto_ptr<SerializedType>(new STAmount(name));
|
||||||
|
|
||||||
|
case STI_HASH128:
|
||||||
|
return std::auto_ptr<SerializedType>(new STHash128(name));
|
||||||
|
|
||||||
case STI_HASH160:
|
case STI_HASH160:
|
||||||
return new STHash160(name);
|
return std::auto_ptr<SerializedType>(new STHash160(name));
|
||||||
|
|
||||||
case STI_HASH256:
|
case STI_HASH256:
|
||||||
return new STHash256(name);
|
return std::auto_ptr<SerializedType>(new STHash256(name));
|
||||||
|
|
||||||
case STI_VL:
|
case STI_VL:
|
||||||
return new STVariableLength(name);
|
return std::auto_ptr<SerializedType>(new STVariableLength(name));
|
||||||
|
|
||||||
case STI_TL:
|
case STI_TL:
|
||||||
return new STTaggedList(name);
|
return std::auto_ptr<SerializedType>(new STTaggedList(name));
|
||||||
|
|
||||||
case STI_ACCOUNT:
|
case STI_ACCOUNT:
|
||||||
return new STAccount(name);
|
return std::auto_ptr<SerializedType>(new STAccount(name));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(false);
|
throw std::runtime_error("Unknown object type");
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SerializedType* STObject::makeDeserializedObject(SerializedTypeID id, const char *name, SerializerIterator& sit)
|
std::auto_ptr<SerializedType> STObject::makeDeserializedObject(SerializedTypeID id, const char *name,
|
||||||
|
SerializerIterator& sit)
|
||||||
{
|
{
|
||||||
switch(id)
|
switch(id)
|
||||||
{
|
{
|
||||||
|
case STI_NOTPRESENT:
|
||||||
|
return SerializedType::deserialize(name);
|
||||||
|
|
||||||
case STI_UINT16:
|
case STI_UINT16:
|
||||||
return STUInt16::construct(sit, name);
|
return STUInt16::deserialize(sit, name);
|
||||||
|
|
||||||
case STI_UINT32:
|
case STI_UINT32:
|
||||||
return STUInt32::construct(sit, name);
|
return STUInt32::deserialize(sit, name);
|
||||||
|
|
||||||
case STI_UINT64:
|
case STI_UINT64:
|
||||||
return STUInt64::construct(sit, name);
|
return STUInt64::deserialize(sit, name);
|
||||||
|
|
||||||
case STI_AMOUNT:
|
case STI_AMOUNT:
|
||||||
return STAmount::construct(sit, name);
|
return STAmount::deserialize(sit, name);
|
||||||
|
|
||||||
|
case STI_HASH128:
|
||||||
|
return STHash128::deserialize(sit, name);
|
||||||
|
|
||||||
case STI_HASH160:
|
case STI_HASH160:
|
||||||
return STHash160::construct(sit, name);
|
return STHash160::deserialize(sit, name);
|
||||||
|
|
||||||
case STI_HASH256:
|
case STI_HASH256:
|
||||||
return STHash256::construct(sit, name);
|
return STHash256::deserialize(sit, name);
|
||||||
|
|
||||||
case STI_VL:
|
case STI_VL:
|
||||||
return STVariableLength::construct(sit, name);
|
return STVariableLength::deserialize(sit, name);
|
||||||
|
|
||||||
case STI_TL:
|
case STI_TL:
|
||||||
return STTaggedList::construct(sit, name);
|
return STTaggedList::deserialize(sit, name);
|
||||||
|
|
||||||
case STI_ACCOUNT:
|
case STI_ACCOUNT:
|
||||||
return STAccount::construct(sit, name);
|
return STAccount::deserialize(sit, name);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(false);
|
throw std::runtime_error("Unknown object type");
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,13 +97,9 @@ STObject::STObject(SOElement* elem, const char *name) : SerializedType(name), mF
|
|||||||
if (elem->e_type == SOE_FLAGS) mFlagIdx = mType.size();
|
if (elem->e_type == SOE_FLAGS) mFlagIdx = mType.size();
|
||||||
mType.push_back(elem);
|
mType.push_back(elem);
|
||||||
if (elem->e_type == SOE_IFFLAG)
|
if (elem->e_type == SOE_IFFLAG)
|
||||||
giveObject(new SerializedType(elem->e_name));
|
giveObject(makeDefaultObject(STI_NOTPRESENT, elem->e_name));
|
||||||
else
|
else
|
||||||
{
|
giveObject(makeDefaultObject(elem->e_id, elem->e_name));
|
||||||
SerializedType* t = makeDefaultObject(elem->e_id, elem->e_name);
|
|
||||||
if (!t) throw std::runtime_error("invalid transaction element");
|
|
||||||
giveObject(t);
|
|
||||||
}
|
|
||||||
++elem;
|
++elem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,7 +117,7 @@ STObject::STObject(SOElement* elem, SerializerIterator& sit, const char *name) :
|
|||||||
if ((flags&elem->e_flags) == 0)
|
if ((flags&elem->e_flags) == 0)
|
||||||
{
|
{
|
||||||
done = true;
|
done = true;
|
||||||
giveObject(new SerializedType(elem->e_name));
|
giveObject(makeDefaultObject(elem->e_id, elem->e_name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (elem->e_type == SOE_IFNFLAG)
|
else if (elem->e_type == SOE_IFNFLAG)
|
||||||
@@ -119,7 +126,7 @@ STObject::STObject(SOElement* elem, SerializerIterator& sit, const char *name) :
|
|||||||
if ((flags&elem->e_flags) != 0)
|
if ((flags&elem->e_flags) != 0)
|
||||||
{
|
{
|
||||||
done = true;
|
done = true;
|
||||||
giveObject(new SerializedType(elem->e_name));
|
giveObject(makeDefaultObject(STI_NOTPRESENT, elem->e_name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (elem->e_type == SOE_FLAGS)
|
else if (elem->e_type == SOE_FLAGS)
|
||||||
@@ -130,11 +137,7 @@ STObject::STObject(SOElement* elem, SerializerIterator& sit, const char *name) :
|
|||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
if (!done)
|
if (!done)
|
||||||
{
|
giveObject(makeDeserializedObject(elem->e_id, elem->e_name, sit));
|
||||||
SerializedType* t = makeDeserializedObject(elem->e_id, elem->e_name, sit);
|
|
||||||
if (!t) throw std::runtime_error("invalid transaction element");
|
|
||||||
giveObject(t);
|
|
||||||
}
|
|
||||||
elem++;
|
elem++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -279,23 +282,22 @@ uint32 STObject::getFlags(void) const
|
|||||||
|
|
||||||
SerializedType* STObject::makeFieldPresent(SOE_Field field)
|
SerializedType* STObject::makeFieldPresent(SOE_Field field)
|
||||||
{
|
{
|
||||||
SerializedType* ret = NULL;
|
|
||||||
int index = getFieldIndex(field);
|
int index = getFieldIndex(field);
|
||||||
if (index == -1) throw std::runtime_error("Field not found");
|
if (index == -1) throw std::runtime_error("Field not found");
|
||||||
if ((mType[index]->e_type != SOE_IFFLAG) && (mType[index]->e_type != SOE_IFNFLAG))
|
if ((mType[index]->e_type != SOE_IFFLAG) && (mType[index]->e_type != SOE_IFNFLAG))
|
||||||
throw std::runtime_error("field is not optional");
|
throw std::runtime_error("field is not optional");
|
||||||
|
|
||||||
ret = getPIndex(index);
|
SerializedType* f = getPIndex(index);
|
||||||
if (ret->getSType() != STI_NOTPRESENT) return ret;
|
if (f->getSType() != STI_NOTPRESENT) return f;
|
||||||
ret = makeDefaultObject(mType[index]->e_id, mType[index]->e_name);
|
mData.replace(index, makeDefaultObject(mType[index]->e_id, mType[index]->e_name));
|
||||||
mData.replace(index, ret);
|
f = getPIndex(index);
|
||||||
|
|
||||||
if (mType[index]->e_type == SOE_IFFLAG)
|
if (mType[index]->e_type == SOE_IFFLAG)
|
||||||
setFlag(mType[index]->e_flags);
|
setFlag(mType[index]->e_flags);
|
||||||
else if (mType[index]->e_type == SOE_IFNFLAG)
|
else if (mType[index]->e_type == SOE_IFNFLAG)
|
||||||
clearFlag(mType[index]->e_flags);
|
clearFlag(mType[index]->e_flags);
|
||||||
|
|
||||||
return ret;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void STObject::makeFieldAbsent(SOE_Field field)
|
void STObject::makeFieldAbsent(SOE_Field field)
|
||||||
|
|||||||
@@ -54,8 +54,10 @@ protected:
|
|||||||
boost::ptr_vector<SerializedType> mData;
|
boost::ptr_vector<SerializedType> mData;
|
||||||
std::vector<SOElement*> mType;
|
std::vector<SOElement*> mType;
|
||||||
|
|
||||||
static SerializedType* makeDefaultObject(SerializedTypeID id, const char *name);
|
static std::auto_ptr<SerializedType> makeDefaultObject(SerializedTypeID id, const char *name);
|
||||||
static SerializedType* makeDeserializedObject(SerializedTypeID id, const char *name, SerializerIterator&);
|
static std::auto_ptr<SerializedType> makeDeserializedObject(SerializedTypeID id, const char *name,
|
||||||
|
SerializerIterator&);
|
||||||
|
STObject* duplicate() const { return new STObject(*this); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
STObject(const char *n = NULL) : SerializedType(n), mFlagIdx(-1) { ; }
|
STObject(const char *n = NULL) : SerializedType(n), mFlagIdx(-1) { ; }
|
||||||
@@ -65,7 +67,6 @@ public:
|
|||||||
|
|
||||||
int getLength() const;
|
int getLength() const;
|
||||||
SerializedTypeID getSType() const { return STI_OBJECT; }
|
SerializedTypeID getSType() const { return STI_OBJECT; }
|
||||||
STObject* duplicate() const { return new STObject(*this); }
|
|
||||||
virtual bool isEquivalent(const SerializedType& t) const;
|
virtual bool isEquivalent(const SerializedType& t) const;
|
||||||
|
|
||||||
void add(Serializer& s) const;
|
void add(Serializer& s) const;
|
||||||
@@ -74,8 +75,9 @@ 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.duplicate()); return mData.size()-1; }
|
int addObject(const SerializedType& t) { mData.push_back(t.clone()); return mData.size() - 1; }
|
||||||
int giveObject(SerializedType* t) { mData.push_back(t); return mData.size()-1; }
|
int giveObject(std::auto_ptr<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; }
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ protected:
|
|||||||
STObject mMiddleTxn, mInnerTxn;
|
STObject mMiddleTxn, mInnerTxn;
|
||||||
TransactionFormat* mFormat;
|
TransactionFormat* mFormat;
|
||||||
|
|
||||||
|
SerializedTransaction* duplicate() const { return new SerializedTransaction(*this); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SerializedTransaction(SerializerIterator& sit, int length); // -1=all remaining, 0=get from sit
|
SerializedTransaction(SerializerIterator& sit, int length); // -1=all remaining, 0=get from sit
|
||||||
SerializedTransaction(TransactionType type);
|
SerializedTransaction(TransactionType type);
|
||||||
@@ -30,7 +32,6 @@ public:
|
|||||||
// STObject functions
|
// STObject functions
|
||||||
int getLength() const;
|
int getLength() const;
|
||||||
SerializedTypeID getSType() const { return STI_TRANSACTION; }
|
SerializedTypeID getSType() const { return STI_TRANSACTION; }
|
||||||
SerializedTransaction* duplicate() const { return new SerializedTransaction(*this); }
|
|
||||||
std::string getFullText() const;
|
std::string getFullText() const;
|
||||||
std::string getText() const;
|
std::string getText() const;
|
||||||
void add(Serializer& s) const { getTransaction(s, true); }
|
void add(Serializer& s) const { getTransaction(s, true); }
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ class SerializedType
|
|||||||
protected:
|
protected:
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
|
virtual SerializedType* duplicate() const { return new SerializedType(name); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SerializedType() : name(NULL) { ; }
|
SerializedType() : name(NULL) { ; }
|
||||||
@@ -33,12 +35,15 @@ public:
|
|||||||
SerializedType(const SerializedType& n) : name(n.name) { ; }
|
SerializedType(const SerializedType& n) : name(n.name) { ; }
|
||||||
virtual ~SerializedType() { ; }
|
virtual ~SerializedType() { ; }
|
||||||
|
|
||||||
|
static std::auto_ptr<SerializedType> deserialize(const char *name)
|
||||||
|
{ return std::auto_ptr<SerializedType>(new SerializedType(name)); }
|
||||||
|
|
||||||
void setName(const char *n) { name=n; }
|
void setName(const char *n) { name=n; }
|
||||||
const char *getName() const { return name; }
|
const char *getName() const { return name; }
|
||||||
|
|
||||||
virtual int getLength() const { return 0; }
|
virtual int getLength() const { return 0; }
|
||||||
virtual SerializedTypeID getSType() const { return STI_NOTPRESENT; }
|
virtual SerializedTypeID getSType() const { return STI_NOTPRESENT; }
|
||||||
virtual SerializedType* duplicate() const { return new SerializedType(name); }
|
std::auto_ptr<SerializedType> clone() const { return std::auto_ptr<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
|
||||||
@@ -49,12 +54,12 @@ public:
|
|||||||
virtual bool isEquivalent(const SerializedType& t) const { return true; }
|
virtual bool isEquivalent(const SerializedType& t) const { return true; }
|
||||||
|
|
||||||
bool operator==(const SerializedType& t) const
|
bool operator==(const SerializedType& t) const
|
||||||
{ return (getSType()==t.getSType()) && isEquivalent(t); }
|
{ return (getSType() == t.getSType()) && isEquivalent(t); }
|
||||||
bool operator!=(const SerializedType& t) const
|
bool operator!=(const SerializedType& t) const
|
||||||
{ return (getSType()!=t.getSType()) || !isEquivalent(t); }
|
{ return (getSType() != t.getSType()) || !isEquivalent(t); }
|
||||||
};
|
};
|
||||||
|
|
||||||
inline SerializedType* new_clone(const SerializedType& s) { return s.duplicate(); }
|
inline SerializedType* new_clone(const SerializedType& s) { return s.clone().release(); }
|
||||||
inline void delete_clone(const SerializedType* s) { boost::checked_delete(s); }
|
inline void delete_clone(const SerializedType* s) { boost::checked_delete(s); }
|
||||||
|
|
||||||
class STUInt8 : public SerializedType
|
class STUInt8 : public SerializedType
|
||||||
@@ -62,15 +67,18 @@ class STUInt8 : public SerializedType
|
|||||||
protected:
|
protected:
|
||||||
unsigned char value;
|
unsigned char value;
|
||||||
|
|
||||||
|
STUInt8* duplicate() const { return new STUInt8(name, value); }
|
||||||
|
static STUInt8* construct(SerializerIterator&, const char *name = NULL);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
STUInt8(unsigned char v=0) : value(v) { ; }
|
STUInt8(unsigned char v=0) : value(v) { ; }
|
||||||
STUInt8(const char *n, unsigned char v=0) : SerializedType(n), value(v) { ; }
|
STUInt8(const char *n, unsigned char v=0) : SerializedType(n), value(v) { ; }
|
||||||
static STUInt8* construct(SerializerIterator&, const char *name = NULL);
|
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char *name)
|
||||||
|
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
int getLength() const { return 1; }
|
int getLength() const { return 1; }
|
||||||
SerializedTypeID getSType() const { return STI_UINT8; }
|
SerializedTypeID getSType() const { return STI_UINT8; }
|
||||||
STUInt8* duplicate() const { return new STUInt8(name, value); }
|
|
||||||
std::string getText() const;
|
std::string getText() const;
|
||||||
void add(Serializer& s) const { s.add8(value); }
|
void add(Serializer& s) const { s.add8(value); }
|
||||||
|
|
||||||
@@ -87,15 +95,18 @@ class STUInt16 : public SerializedType
|
|||||||
protected:
|
protected:
|
||||||
uint16 value;
|
uint16 value;
|
||||||
|
|
||||||
|
STUInt16* duplicate() const { return new STUInt16(name, value); }
|
||||||
|
static STUInt16* construct(SerializerIterator&, const char *name = NULL);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
STUInt16(uint16 v=0) : value(v) { ; }
|
STUInt16(uint16 v=0) : value(v) { ; }
|
||||||
STUInt16(const char *n, uint16 v=0) : SerializedType(n), value(v) { ; }
|
STUInt16(const char *n, uint16 v=0) : SerializedType(n), value(v) { ; }
|
||||||
static STUInt16* construct(SerializerIterator&, const char *name = NULL);
|
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char *name)
|
||||||
|
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
int getLength() const { return 2; }
|
int getLength() const { return 2; }
|
||||||
SerializedTypeID getSType() const { return STI_UINT16; }
|
SerializedTypeID getSType() const { return STI_UINT16; }
|
||||||
STUInt16* duplicate() const { return new STUInt16(name, value); }
|
|
||||||
std::string getText() const;
|
std::string getText() const;
|
||||||
void add(Serializer& s) const { s.add16(value); }
|
void add(Serializer& s) const { s.add16(value); }
|
||||||
|
|
||||||
@@ -112,15 +123,18 @@ class STUInt32 : public SerializedType
|
|||||||
protected:
|
protected:
|
||||||
uint32 value;
|
uint32 value;
|
||||||
|
|
||||||
|
STUInt32* duplicate() const { return new STUInt32(name, value); }
|
||||||
|
static STUInt32* construct(SerializerIterator&, const char *name = NULL);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
STUInt32(uint32 v=0) : value(v) { ; }
|
STUInt32(uint32 v=0) : value(v) { ; }
|
||||||
STUInt32(const char *n, uint32 v=0) : SerializedType(n), value(v) { ; }
|
STUInt32(const char *n, uint32 v=0) : SerializedType(n), value(v) { ; }
|
||||||
static STUInt32* construct(SerializerIterator&, const char *name = NULL);
|
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char *name)
|
||||||
|
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
int getLength() const { return 4; }
|
int getLength() const { return 4; }
|
||||||
SerializedTypeID getSType() const { return STI_UINT32; }
|
SerializedTypeID getSType() const { return STI_UINT32; }
|
||||||
STUInt32* duplicate() const { return new STUInt32(name, value); }
|
|
||||||
std::string getText() const;
|
std::string getText() const;
|
||||||
void add(Serializer& s) const { s.add32(value); }
|
void add(Serializer& s) const { s.add32(value); }
|
||||||
|
|
||||||
@@ -137,15 +151,18 @@ class STUInt64 : public SerializedType
|
|||||||
protected:
|
protected:
|
||||||
uint64 value;
|
uint64 value;
|
||||||
|
|
||||||
|
STUInt64* duplicate() const { return new STUInt64(name, value); }
|
||||||
|
static STUInt64* construct(SerializerIterator&, const char *name = NULL);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
STUInt64(uint64 v=0) : value(v) { ; }
|
STUInt64(uint64 v=0) : value(v) { ; }
|
||||||
STUInt64(const char *n, uint64 v=0) : SerializedType(n), value(v) { ; }
|
STUInt64(const char *n, uint64 v=0) : SerializedType(n), value(v) { ; }
|
||||||
static STUInt64* construct(SerializerIterator&, const char *name = NULL);
|
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char *name)
|
||||||
|
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
int getLength() const { return 8; }
|
int getLength() const { return 8; }
|
||||||
SerializedTypeID getSType() const { return STI_UINT64; }
|
SerializedTypeID getSType() const { return STI_UINT64; }
|
||||||
STUInt64* duplicate() const { return new STUInt64(name, value); }
|
|
||||||
std::string getText() const;
|
std::string getText() const;
|
||||||
void add(Serializer& s) const { s.add64(value); }
|
void add(Serializer& s) const { s.add64(value); }
|
||||||
|
|
||||||
@@ -175,6 +192,8 @@ protected:
|
|||||||
uint64 value;
|
uint64 value;
|
||||||
|
|
||||||
void canonicalize();
|
void canonicalize();
|
||||||
|
STAmount* duplicate() const { return new STAmount(name, offset, value); }
|
||||||
|
static STAmount* construct(SerializerIterator&, const char *name = NULL);
|
||||||
|
|
||||||
static const int cMinOffset=-96, cMaxOffset=80;
|
static const int cMinOffset=-96, cMaxOffset=80;
|
||||||
static const uint64 cMinValue=1000000000000000ull, cMaxValue=9999999999999999ull;
|
static const uint64 cMinValue=1000000000000000ull, cMaxValue=9999999999999999ull;
|
||||||
@@ -184,11 +203,11 @@ public:
|
|||||||
{ canonicalize(); } // (1,0)=$1 (1,-2)=$.01 (100,0)=(10000,-2)=$.01
|
{ canonicalize(); } // (1,0)=$1 (1,-2)=$.01 (100,0)=(10000,-2)=$.01
|
||||||
STAmount(const char *n, uint64 v = 0, int off = 0) : SerializedType(n), offset(off), value(v)
|
STAmount(const char *n, uint64 v = 0, int off = 0) : SerializedType(n), offset(off), value(v)
|
||||||
{ canonicalize(); }
|
{ canonicalize(); }
|
||||||
static STAmount* construct(SerializerIterator&, const char *name = NULL);
|
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char *name)
|
||||||
|
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
int getLength() const { return 8; }
|
int getLength() const { return 8; }
|
||||||
SerializedTypeID getSType() const { return STI_AMOUNT; }
|
SerializedTypeID getSType() const { return STI_AMOUNT; }
|
||||||
STAmount* duplicate() const { return new STAmount(name, offset, value); }
|
|
||||||
std::string getText() const;
|
std::string getText() const;
|
||||||
std::string getRaw() const;
|
std::string getRaw() const;
|
||||||
void add(Serializer& s) const;
|
void add(Serializer& s) const;
|
||||||
@@ -245,17 +264,20 @@ class STHash128 : public SerializedType
|
|||||||
protected:
|
protected:
|
||||||
uint128 value;
|
uint128 value;
|
||||||
|
|
||||||
|
STHash128* duplicate() const { return new STHash128(name, value); }
|
||||||
|
static STHash128* construct(SerializerIterator&, const char *name = NULL);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
STHash128(const uint128& v) : value(v) { ; }
|
STHash128(const uint128& v) : value(v) { ; }
|
||||||
STHash128(const char *n, const uint128& v) : SerializedType(n), value(v) { ; }
|
STHash128(const char *n, const uint128& v) : SerializedType(n), value(v) { ; }
|
||||||
STHash128(const char *n) : SerializedType(n) { ; }
|
STHash128(const char *n) : SerializedType(n) { ; }
|
||||||
STHash128() { ; }
|
STHash128() { ; }
|
||||||
static STHash128* construct(SerializerIterator&, const char *name = NULL);
|
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char *name)
|
||||||
|
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
int getLength() const { return 20; }
|
int getLength() const { return 20; }
|
||||||
SerializedTypeID getSType() const { return STI_HASH128; }
|
SerializedTypeID getSType() const { return STI_HASH128; }
|
||||||
STHash128* duplicate() const { return new STHash128(name, value); }
|
|
||||||
virtual std::string getText() const;
|
virtual std::string getText() const;
|
||||||
void add(Serializer& s) const { s.add128(value); }
|
void add(Serializer& s) const { s.add128(value); }
|
||||||
|
|
||||||
@@ -272,17 +294,20 @@ class STHash160 : public SerializedType
|
|||||||
protected:
|
protected:
|
||||||
uint160 value;
|
uint160 value;
|
||||||
|
|
||||||
|
STHash160* duplicate() const { return new STHash160(name, value); }
|
||||||
|
static STHash160* construct(SerializerIterator&, const char *name = NULL);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
STHash160(const uint160& v) : value(v) { ; }
|
STHash160(const uint160& v) : value(v) { ; }
|
||||||
STHash160(const char *n, const uint160& v) : SerializedType(n), value(v) { ; }
|
STHash160(const char *n, const uint160& v) : SerializedType(n), value(v) { ; }
|
||||||
STHash160(const char *n) : SerializedType(n) { ; }
|
STHash160(const char *n) : SerializedType(n) { ; }
|
||||||
STHash160() { ; }
|
STHash160() { ; }
|
||||||
static STHash160* construct(SerializerIterator&, const char *name = NULL);
|
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char *name)
|
||||||
|
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
int getLength() const { return 20; }
|
int getLength() const { return 20; }
|
||||||
SerializedTypeID getSType() const { return STI_HASH160; }
|
SerializedTypeID getSType() const { return STI_HASH160; }
|
||||||
STHash160* duplicate() const { return new STHash160(name, value); }
|
|
||||||
virtual std::string getText() const;
|
virtual std::string getText() const;
|
||||||
void add(Serializer& s) const { s.add160(value); }
|
void add(Serializer& s) const { s.add160(value); }
|
||||||
|
|
||||||
@@ -299,17 +324,20 @@ class STHash256 : public SerializedType
|
|||||||
protected:
|
protected:
|
||||||
uint256 value;
|
uint256 value;
|
||||||
|
|
||||||
|
STHash256* duplicate() const { return new STHash256(name, value); }
|
||||||
|
static STHash256* construct(SerializerIterator&, const char *name = NULL);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
STHash256(const uint256& v) : value(v) { ; }
|
STHash256(const uint256& v) : value(v) { ; }
|
||||||
STHash256(const char *n, const uint256& v) : SerializedType(n), value(v) { ; }
|
STHash256(const char *n, const uint256& v) : SerializedType(n), value(v) { ; }
|
||||||
STHash256(const char *n) : SerializedType(n) { ; }
|
STHash256(const char *n) : SerializedType(n) { ; }
|
||||||
STHash256() { ; }
|
STHash256() { ; }
|
||||||
static STHash256* construct(SerializerIterator&, const char *name = NULL);
|
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char *name)
|
||||||
|
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
int getLength() const { return 32; }
|
int getLength() const { return 32; }
|
||||||
SerializedTypeID getSType() const { return STI_HASH256; }
|
SerializedTypeID getSType() const { return STI_HASH256; }
|
||||||
STHash256* duplicate() const { return new STHash256(name, value); }
|
|
||||||
std::string getText() const;
|
std::string getText() const;
|
||||||
void add(Serializer& s) const { s.add256(value); }
|
void add(Serializer& s) const { s.add256(value); }
|
||||||
|
|
||||||
@@ -326,6 +354,9 @@ class STVariableLength : public SerializedType
|
|||||||
protected:
|
protected:
|
||||||
std::vector<unsigned char> value;
|
std::vector<unsigned char> value;
|
||||||
|
|
||||||
|
virtual STVariableLength* duplicate() const { return new STVariableLength(name, value); }
|
||||||
|
static STVariableLength* construct(SerializerIterator&, const char *name = NULL);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
STVariableLength(const std::vector<unsigned char>& v) : value(v) { ; }
|
STVariableLength(const std::vector<unsigned char>& v) : value(v) { ; }
|
||||||
@@ -333,11 +364,11 @@ public:
|
|||||||
STVariableLength(const char *n) : SerializedType(n) { ; }
|
STVariableLength(const char *n) : SerializedType(n) { ; }
|
||||||
STVariableLength(SerializerIterator&, const char *name = NULL);
|
STVariableLength(SerializerIterator&, const char *name = NULL);
|
||||||
STVariableLength() { ; }
|
STVariableLength() { ; }
|
||||||
static STVariableLength* construct(SerializerIterator&, const char *name = NULL);
|
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char *name)
|
||||||
|
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
int getLength() const;
|
int getLength() const;
|
||||||
virtual SerializedTypeID getSType() const { return STI_VL; }
|
virtual SerializedTypeID getSType() const { return STI_VL; }
|
||||||
virtual STVariableLength* duplicate() const { return new STVariableLength(name, value); }
|
|
||||||
virtual std::string getText() const;
|
virtual std::string getText() const;
|
||||||
void add(Serializer& s) const { s.addVL(value); }
|
void add(Serializer& s) const { s.addVL(value); }
|
||||||
|
|
||||||
@@ -353,16 +384,20 @@ public:
|
|||||||
|
|
||||||
class STAccount : public STVariableLength
|
class STAccount : public STVariableLength
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
virtual STAccount* duplicate() const { return new STAccount(name, value); }
|
||||||
|
static STAccount* construct(SerializerIterator&, const char *name = NULL);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
STAccount(const std::vector<unsigned char>& v) : STVariableLength(v) { ; }
|
STAccount(const std::vector<unsigned char>& v) : STVariableLength(v) { ; }
|
||||||
STAccount(const char *n, const std::vector<unsigned char>& v) : STVariableLength(n, v) { ; }
|
STAccount(const char *n, const std::vector<unsigned char>& v) : STVariableLength(n, v) { ; }
|
||||||
STAccount(const char *n) : STVariableLength(n) { ; }
|
STAccount(const char *n) : STVariableLength(n) { ; }
|
||||||
STAccount() { ; }
|
STAccount() { ; }
|
||||||
static STAccount* construct(SerializerIterator&, const char *name = NULL);
|
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char *name)
|
||||||
|
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
SerializedTypeID getSType() const { return STI_ACCOUNT; }
|
SerializedTypeID getSType() const { return STI_ACCOUNT; }
|
||||||
virtual STAccount* duplicate() const { return new STAccount(name, value); }
|
|
||||||
std::string getText() const;
|
std::string getText() const;
|
||||||
|
|
||||||
NewcoinAddress getValueNCA() const;
|
NewcoinAddress getValueNCA() const;
|
||||||
@@ -378,17 +413,20 @@ class STTaggedList : public SerializedType
|
|||||||
protected:
|
protected:
|
||||||
std::vector<TaggedListItem> value;
|
std::vector<TaggedListItem> value;
|
||||||
|
|
||||||
|
STTaggedList* duplicate() const { return new STTaggedList(name, value); }
|
||||||
|
static STTaggedList* construct(SerializerIterator&, const char *name = NULL);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
STTaggedList() { ; }
|
STTaggedList() { ; }
|
||||||
STTaggedList(const char *n) : SerializedType(n) { ; }
|
STTaggedList(const char *n) : SerializedType(n) { ; }
|
||||||
STTaggedList(const std::vector<TaggedListItem>& v) : value(v) { ; }
|
STTaggedList(const std::vector<TaggedListItem>& v) : value(v) { ; }
|
||||||
STTaggedList(const char *n, const std::vector<TaggedListItem>& v) : SerializedType(n), value(v) { ; }
|
STTaggedList(const char *n, const std::vector<TaggedListItem>& v) : SerializedType(n), value(v) { ; }
|
||||||
static STTaggedList* construct(SerializerIterator&, const char *name = NULL);
|
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char *name)
|
||||||
|
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||||
|
|
||||||
int getLength() const;
|
int getLength() const;
|
||||||
SerializedTypeID getSType() const { return STI_TL; }
|
SerializedTypeID getSType() const { return STI_TL; }
|
||||||
STTaggedList* duplicate() const { return new STTaggedList(name, value); }
|
|
||||||
std::string getText() const;
|
std::string getText() const;
|
||||||
void add(Serializer& s) const { if(s.addTaggedList(value)<0) throw(0); }
|
void add(Serializer& s) const { if(s.addTaggedList(value)<0) throw(0); }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user