More work on the new serialized types.

This commit is contained in:
JoelKatz
2012-03-14 17:15:41 -07:00
parent e7c350ffec
commit 47e1f5a1d4
4 changed files with 133 additions and 27 deletions

View File

@@ -26,10 +26,8 @@ public:
virtual SerializedType* duplicate() const { return new SerializedType(); }
virtual std::string getText() const { return std::string(); }
virtual std::string getSQL() const { return std::string(); }
virtual std::vector<unsigned char> serialize() const;
virtual int add(std::vector<unsigned char>&) const { return 0; }
virtual void add(Serializer& s) const { return; }
SerializedType* new_clone(const SerializedType& s) { return s.duplicate(); }
void delete_clone(const SerializedType* s) { boost::checked_delete(s); }
@@ -43,14 +41,13 @@ protected:
public:
STUInt8(unsigned char v=0) : value(v) { ; }
static STUInt8* construct(const std::vector<unsigned char>&, int start_offset, int& length_consumed);
static STUInt8* construct(SerializerIterator&);
int getLength() const { return 1; }
SerializedTypeID getType() const { return STI_UINT8; }
STUInt8 *duplicate() const { return new STUInt8(value); }
std::string getText() const;
std::string getSQL() const;
virtual int add(std::vector<unsigned char>&) const;
virtual void add(Serializer& s) const { s.add8(value); }
unsigned char getValue() const { return value; }
void setValue(unsigned char v) { value=v; }
@@ -67,14 +64,13 @@ protected:
public:
STUInt16(uint16 v=0) : value(v) { ; }
static STUInt16* construct(const std::vector<unsigned char>&, int start_offset, int& length_consumed);
static STUInt16* construct(SerializerIterator&);
int getLength() const { return 2; }
SerializedTypeID getType() const { return STI_UINT16; }
STUInt16 *duplicate() const { return new STUInt16(value); }
std::string getText() const;
std::string getSQL() const;
virtual int add(std::vector<unsigned char>&) const;
virtual void add(Serializer& s) const { s.add16(value); }
uint16 getValue() const { return value; }
void setValue(uint16 v) { value=v; }
@@ -91,14 +87,13 @@ protected:
public:
STUInt32(uint32 v=0) : value(v) { ; }
static STUInt32* construct(const std::vector<unsigned char>&, int start_offset, int& length_consumed);
static STUInt32* construct(SerializerIterator&);
int getLength() const { return 4; }
SerializedTypeID getType() const { return STI_UINT32; }
STUInt32 *duplicate() const { return new STUInt32(value); }
std::string getText() const;
std::string getSQL() const;
virtual int add(std::vector<unsigned char>&) const;
virtual void add(Serializer& s) const { s.add32(value); }
uint32 getValue() const { return value; }
void setValue(uint32 v) { value=v; }
@@ -115,14 +110,13 @@ protected:
public:
STUInt64(uint64 v=0) : value(v) { ; }
static STUInt64* construct(const std::vector<unsigned char>&, int start_offset, int& length_consumed);
static STUInt64* construct(SerializerIterator&);
int getLength() const { return 8; }
SerializedTypeID getType() const { return STI_UINT64; }
STUInt64 *duplicate() const { return new STUInt64(value); }
std::string getText() const;
std::string getSQL() const;
virtual int add(std::vector<unsigned char>&) const;
virtual void add(Serializer& s) const { s.add64(value); }
uint64 getValue() const { return value; }
void setValue(uint64 v) { value=v; }
@@ -140,14 +134,13 @@ public:
STUHash160(const uint160& v) : value(v) { ; }
STUHash160() { ; }
static STUHash160* construct(const std::vector<unsigned char>&, int start_offset, int& length_consumed);
static STUHash160* construct(SerializerIterator&);
int getLength() const { return 20; }
SerializedTypeID getType() const { return STI_HASH160; }
STUHash160 *duplicate() const { return new STUHash160(value); }
std::string getText() const;
std::string getSQL() const;
virtual int add(std::vector<unsigned char>&) const;
virtual void add(Serializer& s) const { s.add160(value); }
const uint160& getValue() const { return value; }
void setValue(const uint160& v) { value=v; }
@@ -165,14 +158,13 @@ public:
STUHash256(const uint256& v) : value(v) { ; }
STUHash256() { ; }
static STUHash256* construct(const std::vector<unsigned char>&, int start_offset, int& length_consumed);
static STUHash256* construct(SerializerIterator&);
int getLength() const { return 32; }
SerializedTypeID getType() const { return STI_HASH256; }
STUHash256 *duplicate() const { return new STUHash256(value); }
std::string getText() const;
std::string getSQL() const;
virtual int add(std::vector<unsigned char>&) const;
virtual void add(Serializer& s) const { s.add256(value); }
const uint256& getValue() const { return value; }
void setValue(const uint256& v) { value=v; }
@@ -190,14 +182,13 @@ public:
STUVariableLength(const std::vector<unsigned char>& v) : value(v) { ; }
STUVariableLength() { ; }
static STUVariableLength* construct(const std::vector<unsigned char>&, int start_offset, int& length_consumed);
static STUVariableLength* construct(SerializerIterator&);
int getLength() const;
SerializedTypeID getType() const { return STI_VL; }
STUVariableLength *duplicate() const { return new STUVariableLength(value); }
std::string getText() const;
std::string getSQL() const;
virtual int add(std::vector<unsigned char>&) const;
virtual void add(Serializer& s) const { s.addVL(value); }
const std::vector<unsigned char>& peekValue() const { return value; }
std::vector<unsigned char>& peekValue() { return value; }
@@ -217,14 +208,13 @@ public:
STUTaggedList(const std::list<TaggedListItem>& v) : value(v) { ; }
STUTaggedList() { ; }
static STUTaggedList* construct(const std::vector<unsigned char>&, int start_offset, int& length_consumed);
static STUTaggedList* construct(SerializerIterator&);
int getLength() const;
SerializedTypeID getType() const { return STI_TL; }
STUTaggedList *duplicate() const { return new STUTaggedList(value); }
std::string getText() const;
std::string getSQL() const;
virtual int add(std::vector<unsigned char>&) const;
virtual void add(Serializer& s) const { s.addTaggedList(value); }
const std::list<TaggedListItem>& peekValue() const { return value; }
std::list<TaggedListItem>& peekValue() { return value; }