mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
More serialization work.
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
|
||||
struct SOElement
|
||||
{ // An element in the description of a serialized object
|
||||
SOE_Field e_field;
|
||||
SField::ref e_field;
|
||||
SOE_Flags flags;
|
||||
};
|
||||
|
||||
@@ -24,13 +24,17 @@ protected:
|
||||
std::vector<const SOElement*> mType;
|
||||
|
||||
STObject* duplicate() const { return new STObject(*this); }
|
||||
static STObject* construct(SerializerIterator&, SField::ref);
|
||||
|
||||
public:
|
||||
STObject(FieldName *n = NULL) : SerializedType(n) { ; }
|
||||
STObject(const SOElement *t, FieldName *n = NULL);
|
||||
STObject(const SOElement *t, SerializerIterator& u, FieldName *n = NULL);
|
||||
STObject(SField *n = NULL) : SerializedType(n) { ; }
|
||||
STObject(const SOElement *t, SField *n = NULL);
|
||||
STObject(const SOElement *t, SerializerIterator& u, SField *n = NULL);
|
||||
virtual ~STObject() { ; }
|
||||
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
void set(const SOElement* t);
|
||||
void set(const SOElement* t, SerializerIterator& u, int depth = 0);
|
||||
|
||||
@@ -61,54 +65,54 @@ public:
|
||||
const SerializedType* peekAtPIndex(int offset) const { return &(mData[offset]); }
|
||||
SerializedType* getPIndex(int offset) { return &(mData[offset]); }
|
||||
|
||||
int getFieldIndex(SOE_Field field) const;
|
||||
SOE_Field getFieldSType(int index) const;
|
||||
int getFieldIndex(SField::ref field) const;
|
||||
SField::ref getFieldSType(int index) const;
|
||||
|
||||
const SerializedType& peekAtField(SOE_Field field) const;
|
||||
SerializedType& getField(SOE_Field field);
|
||||
const SerializedType* peekAtPField(SOE_Field field) const;
|
||||
SerializedType* getPField(SOE_Field field);
|
||||
const SOElement* getFieldType(SOE_Field field) const;
|
||||
const SerializedType& peekAtField(SField::ref field) const;
|
||||
SerializedType& getField(SField::ref field);
|
||||
const SerializedType* peekAtPField(SField::ref field) const;
|
||||
SerializedType* getPField(SField::ref field);
|
||||
const SOElement* getFieldType(SField::ref field) const;
|
||||
|
||||
// these throw if the field type doesn't match, or return default values if the
|
||||
// field is optional but not present
|
||||
std::string getFieldString(SOE_Field field) const;
|
||||
unsigned char getValueFieldU8(SOE_Field field) const;
|
||||
uint16 getValueFieldU16(SOE_Field field) const;
|
||||
uint32 getValueFieldU32(SOE_Field field) const;
|
||||
uint64 getValueFieldU64(SOE_Field field) const;
|
||||
uint128 getValueFieldH128(SOE_Field field) const;
|
||||
uint160 getValueFieldH160(SOE_Field field) const;
|
||||
uint256 getValueFieldH256(SOE_Field field) const;
|
||||
NewcoinAddress getValueFieldAccount(SOE_Field field) const;
|
||||
std::vector<unsigned char> getValueFieldVL(SOE_Field field) const;
|
||||
std::vector<TaggedListItem> getValueFieldTL(SOE_Field field) const;
|
||||
STAmount getValueFieldAmount(SOE_Field field) const;
|
||||
STPathSet getValueFieldPathSet(SOE_Field field) const;
|
||||
STVector256 getValueFieldV256(SOE_Field field) const;
|
||||
std::string getFieldString(SField::ref field) const;
|
||||
unsigned char getValueFieldU8(SField::ref field) const;
|
||||
uint16 getValueFieldU16(SField::ref field) const;
|
||||
uint32 getValueFieldU32(SField::ref field) const;
|
||||
uint64 getValueFieldU64(SField::ref field) const;
|
||||
uint128 getValueFieldH128(SField::ref field) const;
|
||||
uint160 getValueFieldH160(SField::ref field) const;
|
||||
uint256 getValueFieldH256(SField::ref field) const;
|
||||
NewcoinAddress getValueFieldAccount(SField::ref field) const;
|
||||
std::vector<unsigned char> getValueFieldVL(SField::ref field) const;
|
||||
std::vector<TaggedListItem> getValueFieldTL(SField::ref field) const;
|
||||
STAmount getValueFieldAmount(SField::ref field) const;
|
||||
STPathSet getValueFieldPathSet(SField::ref field) const;
|
||||
STVector256 getValueFieldV256(SField::ref field) const;
|
||||
|
||||
void setValueFieldU8(SOE_Field field, unsigned char);
|
||||
void setValueFieldU16(SOE_Field field, uint16);
|
||||
void setValueFieldU32(SOE_Field field, uint32);
|
||||
void setValueFieldU64(SOE_Field field, uint64);
|
||||
void setValueFieldH128(SOE_Field field, const uint128&);
|
||||
void setValueFieldH160(SOE_Field field, const uint160&);
|
||||
void setValueFieldH256(SOE_Field field, const uint256&);
|
||||
void setValueFieldVL(SOE_Field field, const std::vector<unsigned char>&);
|
||||
void setValueFieldTL(SOE_Field field, const std::vector<TaggedListItem>&);
|
||||
void setValueFieldAccount(SOE_Field field, const uint160&);
|
||||
void setValueFieldAccount(SOE_Field field, const NewcoinAddress& addr)
|
||||
void setValueFieldU8(SField::ref field, unsigned char);
|
||||
void setValueFieldU16(SField::ref field, uint16);
|
||||
void setValueFieldU32(SField::ref field, uint32);
|
||||
void setValueFieldU64(SField::ref field, uint64);
|
||||
void setValueFieldH128(SField::ref field, const uint128&);
|
||||
void setValueFieldH160(SField::ref field, const uint160&);
|
||||
void setValueFieldH256(SField::ref field, const uint256&);
|
||||
void setValueFieldVL(SField::ref field, const std::vector<unsigned char>&);
|
||||
void setValueFieldTL(SField::ref field, const std::vector<TaggedListItem>&);
|
||||
void setValueFieldAccount(SField::ref field, const uint160&);
|
||||
void setValueFieldAccount(SField::ref field, const NewcoinAddress& addr)
|
||||
{ setValueFieldAccount(field, addr.getAccountID()); }
|
||||
void setValueFieldAmount(SOE_Field field, const STAmount&);
|
||||
void setValueFieldPathSet(SOE_Field field, const STPathSet&);
|
||||
void setValueFieldV256(SOE_Field field, const STVector256& v);
|
||||
void setValueFieldAmount(SField::ref field, const STAmount&);
|
||||
void setValueFieldPathSet(SField::ref field, const STPathSet&);
|
||||
void setValueFieldV256(SField::ref field, const STVector256& v);
|
||||
|
||||
bool isFieldPresent(SOE_Field field) const;
|
||||
SerializedType* makeFieldPresent(SOE_Field field);
|
||||
void makeFieldAbsent(SOE_Field field);
|
||||
bool isFieldPresent(SField::ref field) const;
|
||||
SerializedType* makeFieldPresent(SField::ref field);
|
||||
void makeFieldAbsent(SField::ref field);
|
||||
|
||||
static std::auto_ptr<SerializedType> makeDefaultObject(SerializedTypeID id, FieldName *name);
|
||||
static std::auto_ptr<SerializedType> makeDeserializedObject(SerializedTypeID id, FieldName *name,
|
||||
static std::auto_ptr<SerializedType> makeDefaultObject(SerializedTypeID id, SField *name);
|
||||
static std::auto_ptr<SerializedType> makeDeserializedObject(SerializedTypeID id, SField *name,
|
||||
SerializerIterator&, int depth);
|
||||
|
||||
static void unitTest();
|
||||
@@ -128,16 +132,16 @@ protected:
|
||||
|
||||
vector value;
|
||||
|
||||
STArray* duplicate() const { return new STArray(fName, value); }
|
||||
static STArray* construct(SerializerIterator&, FieldName* name = NULL);
|
||||
STArray* duplicate() const { return new STArray(*this); }
|
||||
static STArray* construct(SerializerIterator&, SField::ref);
|
||||
|
||||
public:
|
||||
|
||||
STArray() { ; }
|
||||
STArray(FieldName* f, const vector& v) : SerializedType(f), value(v) { ; }
|
||||
STArray(SField::ref f, const vector& v) : SerializedType(f), value(v) { ; }
|
||||
STArray(vector& v) : value(v) { ; }
|
||||
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, FieldName* name)
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
const vector& getValue() const { return value; }
|
||||
|
||||
Reference in New Issue
Block a user