mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Cleanups.
This commit is contained in:
@@ -49,6 +49,20 @@ SField::ref SField::getField(int code);
|
||||
return *(new SField(code, static_cast<SerializedTypeID>(type), field, NULL));
|
||||
}
|
||||
|
||||
int SField::compare(SField::ref f1, SField::ref f2)
|
||||
{ // -1 = f1 comes before f2, 0 = illegal combination, 1 = f1 comes after f2
|
||||
if ((f1.fieldCode <= 0) || (f2.fieldCode <= 0))
|
||||
return 0;
|
||||
|
||||
if (f1.fieldCode < f2.fieldCode)
|
||||
return -1;
|
||||
|
||||
if (f2.fieldCode < f1.fieldCode)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SField::ref SField::getField(int type, int value)
|
||||
{
|
||||
return getField(FIELD_CODE(type, value));
|
||||
|
||||
@@ -69,6 +69,8 @@ public:
|
||||
|
||||
bool operator==(const SField& f) const { return fieldCode == f.fieldCode; }
|
||||
bool operator!=(const SField& f) const { return fieldCode != f.fieldCode; }
|
||||
|
||||
static int compare(SField::ref f1, SField::ref f2);
|
||||
};
|
||||
|
||||
extern SField sfInvalid, sfGeneric;
|
||||
|
||||
@@ -192,9 +192,9 @@ std::string STObject::getFullText() const
|
||||
{
|
||||
std::string ret;
|
||||
bool first = true;
|
||||
if (name != NULL)
|
||||
if (fName->hasName())
|
||||
{
|
||||
ret = name;
|
||||
ret = fName->getName();
|
||||
ret += " = {";
|
||||
}
|
||||
else ret = "{";
|
||||
@@ -213,6 +213,13 @@ std::string STObject::getFullText() const
|
||||
|
||||
void STObject::add(Serializer& s) const
|
||||
{
|
||||
addFieldID(s);
|
||||
addRaw(s);
|
||||
s.addFieldID(STI_OBJECT, 1);
|
||||
}
|
||||
|
||||
void STObject::addRaw(Serializer& s) const
|
||||
{ // FIXME: need to add in sorted order
|
||||
BOOST_FOREACH(const SerializedType& it, mData)
|
||||
it.add(s);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,8 @@ public:
|
||||
virtual SerializedTypeID getSType() const { return STI_OBJECT; }
|
||||
virtual bool isEquivalent(const SerializedType& t) const;
|
||||
|
||||
void add(Serializer& s) const;
|
||||
void add(Serializer& s) const; // with start/end of object
|
||||
virtual void addRaw(Serializer& s) const; // just inner elements
|
||||
Serializer getSerializer() const { Serializer s; add(s); return s; }
|
||||
std::string getFullText() const;
|
||||
std::string getText() const;
|
||||
|
||||
@@ -66,6 +66,8 @@ public:
|
||||
virtual bool isEquivalent(const SerializedType& t) const
|
||||
{ assert(getSType() == STI_NOTPRESENT); return t.getSType() == STI_NOTPRESENT; }
|
||||
|
||||
void addFieldID(Serializer& s) const { s.addFieldID(fName->fieldType, fName->fieldValue); }
|
||||
|
||||
SerializedType& operator=(const SerializedType& t)
|
||||
{ if (!fName->fieldCode) fName = t.fName; return *this; }
|
||||
bool operator==(const SerializedType& t) const
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "key.h"
|
||||
#include "uint256.h"
|
||||
#include "FieldNames.h"
|
||||
|
||||
typedef std::pair<int, std::vector<unsigned char> > TaggedListItem;
|
||||
|
||||
@@ -69,6 +70,7 @@ public:
|
||||
|
||||
bool getFieldID(int& type, int& name, int offset) const;
|
||||
int addFieldID(int type, int name);
|
||||
int addFieldID(SerializedTypeID type, int name);
|
||||
|
||||
// normal hash functions
|
||||
uint160 getRIPEMD160(int size=-1) const;
|
||||
|
||||
Reference in New Issue
Block a user