mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-02 00:45:58 +00:00
Commit for Arthur.
getFullText, object layout. STUObject code.
This commit is contained in:
@@ -27,20 +27,19 @@ protected:
|
|||||||
boost::ptr_vector<SerializedType> data;
|
boost::ptr_vector<SerializedType> data;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
STUObject() { ; }
|
STUObject() : type(NULL) { ; }
|
||||||
virtual ~STUObject();
|
STUObject(SOType *t) : type(t) { ; }
|
||||||
|
STUObject(SOType *t, SerializerIterator& u);
|
||||||
STUObject(const STUObject&);
|
virtual ~STUObject() { ; }
|
||||||
STUObject& operator=(const STUObject&);
|
|
||||||
|
|
||||||
int getLength() const;
|
int getLength() const;
|
||||||
SerializedTypeID getType() const { return STI_OBJECT; }
|
SerializedTypeID getType() const { return STI_OBJECT; }
|
||||||
STUObject* duplicate() const { return new STUObject(*this); }
|
STUObject* duplicate() const { return new STUObject(*this); }
|
||||||
|
|
||||||
void add(Serializer& s) const;
|
void add(Serializer& s) const;
|
||||||
|
std::string getFullText() const;
|
||||||
std::string getText() const;
|
std::string getText() const;
|
||||||
|
|
||||||
|
|
||||||
void addObject(const SerializedType& t) { data.push_back(t.duplicate()); }
|
void addObject(const SerializedType& t) { data.push_back(t.duplicate()); }
|
||||||
void giveObject(SerializedType* t) { data.push_back(t); }
|
void giveObject(SerializedType* t) { data.push_back(t); }
|
||||||
const boost::ptr_vector<SerializedType>& peekData() const { return data; }
|
const boost::ptr_vector<SerializedType>& peekData() const { return data; }
|
||||||
|
|||||||
@@ -4,6 +4,21 @@
|
|||||||
#include "SerializedTypes.h"
|
#include "SerializedTypes.h"
|
||||||
#include "SerializedObject.h"
|
#include "SerializedObject.h"
|
||||||
|
|
||||||
|
std::string SerializedType::getFullText() const
|
||||||
|
{
|
||||||
|
std::string ret;
|
||||||
|
if(getType()!=STI_NOTPRESENT)
|
||||||
|
{
|
||||||
|
if(name!=NULL)
|
||||||
|
{
|
||||||
|
ret=name;
|
||||||
|
ret+=" = ";
|
||||||
|
}
|
||||||
|
ret+=getText();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
STUInt8* STUInt8::construct(SerializerIterator& u)
|
STUInt8* STUInt8::construct(SerializerIterator& u)
|
||||||
{
|
{
|
||||||
return new STUInt8(u.get8());
|
return new STUInt8(u.get8());
|
||||||
@@ -111,3 +126,49 @@ int STUTaggedList::getLength() const
|
|||||||
if(ret<0) throw(0);
|
if(ret<0) throw(0);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string STUObject::getFullText() const
|
||||||
|
{
|
||||||
|
std::string ret;
|
||||||
|
if(name!=NULL)
|
||||||
|
{
|
||||||
|
ret=name;
|
||||||
|
ret+=" = {";
|
||||||
|
}
|
||||||
|
else ret="{";
|
||||||
|
for(boost::ptr_vector<SerializedType>::const_iterator it=data.begin(), end=data.end(); it!=end; ++it)
|
||||||
|
ret+=it->getFullText();
|
||||||
|
ret+="}";
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int STUObject::getLength() const
|
||||||
|
{
|
||||||
|
int ret=0;
|
||||||
|
for(boost::ptr_vector<SerializedType>::const_iterator it=data.begin(), end=data.end(); it!=end; ++it)
|
||||||
|
ret+=it->getLength();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void STUObject::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 ret="{";
|
||||||
|
bool first=false;
|
||||||
|
for(boost::ptr_vector<SerializedType>::const_iterator it=data.begin(), end=data.end(); it!=end; ++it)
|
||||||
|
{
|
||||||
|
if(!first)
|
||||||
|
{
|
||||||
|
ret+=", ";
|
||||||
|
first=false;
|
||||||
|
}
|
||||||
|
ret+=it->getText();
|
||||||
|
}
|
||||||
|
ret+="}";
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,16 +16,25 @@ enum SerializedTypeID
|
|||||||
|
|
||||||
class SerializedType
|
class SerializedType
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
const char *name;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SerializedType() { ; }
|
SerializedType() : name(NULL) { ; }
|
||||||
|
SerializedType(const char *n) : name(n) { ; }
|
||||||
virtual ~SerializedType() { ; }
|
virtual ~SerializedType() { ; }
|
||||||
|
|
||||||
|
void setName(const char *n) { name=n; }
|
||||||
|
const char *getName() { return name; }
|
||||||
|
|
||||||
virtual int getLength() const { return 0; }
|
virtual int getLength() const { return 0; }
|
||||||
virtual SerializedTypeID getType() const { return STI_NOTPRESENT; }
|
virtual SerializedTypeID getType() const { return STI_NOTPRESENT; }
|
||||||
virtual SerializedType* duplicate() const { return new SerializedType(); }
|
virtual SerializedType* duplicate() const { return new SerializedType(); }
|
||||||
|
|
||||||
virtual std::string getText() const { return std::string(); }
|
virtual std::string getFullText() const;
|
||||||
|
virtual std::string getText() const // just the value
|
||||||
|
{ return std::string(); }
|
||||||
|
|
||||||
virtual void add(Serializer& s) const { return; }
|
virtual void add(Serializer& s) const { return; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user