Missing sort.

This commit is contained in:
JoelKatz
2012-09-29 00:30:21 -07:00
parent 4800899c47
commit 3e305871c3
2 changed files with 17 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/bind.hpp>
#include "../json/writer.h"
@@ -129,11 +130,26 @@ void STObject::set(SOElement::ptr elem)
}
}
bool STObject::compare(const SerializedType& f1, const SerializedType& f2)
{
BOOST_FOREACH(SOElement::ptr elem, mType)
{
if (elem->e_field == f1.getFName()) // element one comes first
return true;
if (elem->e_field == f2.getFName()) // element two comes first
return false;
}
assert(false);
return false;
}
void STObject::setType(SOElement::ptrList t)
{
mType.empty();
while (t->flags != SOE_END)
mType.push_back(t++);
std::sort(mData.begin(), mData.end(), boost::bind(&STObject::compare, this, _1, _2));
}
bool STObject::isValidForType()

View File

@@ -28,6 +28,7 @@ protected:
std::vector<SOElement::ptr> mType;
STObject* duplicate() const { return new STObject(*this); }
bool compare(const SerializedType& f1, const SerializedType& f2);
public:
STObject() { ; }