More work on the JSON conversion code.

This commit is contained in:
JoelKatz
2012-10-01 08:32:23 -07:00
parent 98d8823be0
commit c4275c6d80
6 changed files with 157 additions and 20 deletions

View File

@@ -5,6 +5,7 @@
#include <boost/thread/mutex.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/foreach.hpp>
// These must stay at the top of this file
@@ -82,3 +83,15 @@ std::string SField::getName() const
return boost::lexical_cast<std::string>(static_cast<int>(fieldType)) + "/" +
boost::lexical_cast<std::string>(fieldValue);
}
SField::ref SField::getField(const std::string& fieldName)
{ // OPTIMIZEME me with a map. CHECKME this is case sensitive
boost::mutex::scoped_lock sl(mapMutex);
typedef std::pair<const int, SField::ptr> int_sfref_pair;
BOOST_FOREACH(const int_sfref_pair& fieldPair, codeToField)
{
if (fieldPair.second->fieldName == fieldName)
return *(fieldPair.second);
}
return sfInvalid;
}