Type STObject helper functions, 'empty' and 'hasMatchingEntry'.

A small 'isFieldAllowed' bugfix.
This commit is contained in:
JoelKatz
2012-10-26 13:31:24 -07:00
parent 76d4a91814
commit 15547ce839
2 changed files with 13 additions and 0 deletions

View File

@@ -206,6 +206,8 @@ bool STObject::isValidForType()
bool STObject::isFieldAllowed(SField::ref field)
{
if (isFree())
return true;
BOOST_FOREACH(SOElement::ptr elem, mType)
{ // are any required elemnents missing
if (elem->e_field == field)
@@ -242,6 +244,14 @@ std::auto_ptr<SerializedType> STObject::deserialize(SerializerIterator& sit, SFi
return object;
}
bool STObject::hasMatchingEntry(const SerializedType& t)
{
const SerializedType* o = peekAtPField(t.getFName());
if (!o)
return false;
return t == *o;
}
std::string STObject::getFullText() const
{
std::string ret;

View File

@@ -156,6 +156,9 @@ public:
iterator end() { return mData.end(); }
const_iterator begin() const { return mData.begin(); }
const_iterator end() const { return mData.end(); }
bool empty() const { return mData.empty(); }
bool hasMatchingEntry(const SerializedType&);
bool operator==(const STObject& o) const;
bool operator!=(const STObject& o) const { return ! (*this == o); }