STUObject->STObject

This commit is contained in:
JoelKatz
2012-03-22 15:45:22 -07:00
parent 1f3fcd5c65
commit 228b36d734
3 changed files with 21 additions and 18 deletions

View File

@@ -1,13 +1,13 @@
#include "SerializedObject.h"
STUObject::STUObject(SOElement* elem, const char *name) : SerializedType(name)
STObject::STObject(SOElement* elem, const char *name) : SerializedType(name)
{
while(elem->e_id!=STI_DONE)
{
type.push_back(elem);
if( (elem->e_type==SOE_IFFLAG) || (elem->e_type==SOE_IFNFLAG) )
giveObject(new STUObject(elem->e_name));
giveObject(new STObject(elem->e_name));
else switch(elem->e_id)
{
case STI_UINT16:
@@ -42,7 +42,7 @@ STUObject::STUObject(SOElement* elem, const char *name) : SerializedType(name)
}
}
STUObject::STUObject(SOElement* elem, SerializerIterator& sit, const char *name) : SerializedType(name)
STObject::STObject(SOElement* elem, SerializerIterator& sit, const char *name) : SerializedType(name)
{
int flags=-1;
while(elem->e_id!=STI_DONE)
@@ -103,7 +103,7 @@ STUObject::STUObject(SOElement* elem, SerializerIterator& sit, const char *name)
}
}
std::string STUObject::getFullText() const
std::string STObject::getFullText() const
{
std::string ret;
if(name!=NULL)
@@ -118,7 +118,7 @@ std::string STUObject::getFullText() const
return ret;
}
int STUObject::getLength() const
int STObject::getLength() const
{
int ret=0;
for(boost::ptr_vector<SerializedType>::const_iterator it=data.begin(), end=data.end(); it!=end; ++it)
@@ -126,13 +126,13 @@ int STUObject::getLength() const
return ret;
}
void STUObject::add(Serializer& s) const
void STObject::add(Serializer& s) const
{
for(boost::ptr_vector<SerializedType>::const_iterator it=data.begin(), end=data.end(); it!=end; ++it)
it->add(s);
}
std::string STUObject::getText() const
std::string STObject::getText() const
{
std::string ret="{";
bool first=false;

View File

@@ -20,21 +20,21 @@ struct SOElement
int e_flags;
};
class STUObject : public SerializedType
class STObject : public SerializedType
{
protected:
boost::ptr_vector<SerializedType> data;
std::vector<SOElement*> type;
public:
STUObject(const char *n=NULL) : SerializedType(n) { ; }
STUObject(SOElement *t, const char *n=NULL);
STUObject(SOElement *t, SerializerIterator& u, const char *n=NULL);
virtual ~STUObject() { ; }
STObject(const char *n=NULL) : SerializedType(n) { ; }
STObject(SOElement *t, const char *n=NULL);
STObject(SOElement *t, SerializerIterator& u, const char *n=NULL);
virtual ~STObject() { ; }
int getLength() const;
SerializedTypeID getType() const { return STI_OBJECT; }
STUObject* duplicate() const { return new STUObject(*this); }
STObject* duplicate() const { return new STObject(*this); }
void add(Serializer& s) const;
std::string getFullText() const;
@@ -48,6 +48,8 @@ public:
int getCount() const { return data.size(); }
const SerializedType& peekAt(int offset) const { return data[offset]; }
SerializedType& getAt(int offset) { return data[offset]; }
const SerializedType* peekAtP(int offset) const { return &(data[offset]); }
SerializedType* getAtP(int offset) { return &(data[offset]); }
};

View File

@@ -7,25 +7,25 @@
#include "SerializedObject.h"
#include "TransactionFormats.h"
class SerializedTransaction : public STUObject
class SerializedTransaction : public STObject
{
protected:
TransactionType type;
STVariableLength mSignature;
STUObject mMiddleTxn, mInnerTxn;
STObject mMiddleTxn, mInnerTxn;
TransactionFormat* mFormat;
public:
SerializedTransaction(SerializerIterator&, int length);
SerializedTransaction(TransactionType type);
// STUObject functions
// STObject functions
int getLength() const;
SerializedTypeID getType() const { return STI_TRANSACTION; }
SerializedTransaction* duplicate() const { return new SerializedTransaction(*this); }
std::string getFullText() const;
std::string getText() const;
void add(Serializer& s) const;
void add(Serializer& s) const { getTransaction(s, true); }
// outer transaction functions / signature functions
std::vector<unsigned char> getSignature() const;
@@ -57,7 +57,8 @@ public:
void makeITFieldPresent(int index);
// whole transaction functions
int getTransaction(Serializer& s, bool include_length);
int getTransaction(Serializer& s, bool include_length) const;
uint256 getTransactionID() const;
};
#endif