From: <ag...@us...> - 2012-01-30 12:17:06
|
Revision: 2701 http://zoolib.svn.sourceforge.net/zoolib/?rev=2701&view=rev Author: agreen Date: 2012-01-30 12:16:55 +0000 (Mon, 30 Jan 2012) Log Message: ----------- Add Mutable and DMutable. Modified Paths: -------------- trunk/zoolib/source/cxx/zoolib/ZVal_Any.cpp trunk/zoolib/source/cxx/zoolib/ZVal_Any.h Modified: trunk/zoolib/source/cxx/zoolib/ZVal_Any.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_Any.cpp 2012-01-30 12:16:24 UTC (rev 2700) +++ trunk/zoolib/source/cxx/zoolib/ZVal_Any.cpp 2012-01-30 12:16:55 UTC (rev 2701) @@ -92,14 +92,10 @@ } ZVal_Any ZVal_Any::Get(const string8& iName) const - { return this->GetMap().Get(iName); } + { return this->Get<ZMap_Any>().Get(iName); } ZVal_Any& ZVal_Any::Mutable(const string8& iName) - { - if (ZMap_Any* asMap = this->PGetMutable<ZMap_Any>()) - return asMap->Mutable(iName); - return this->Mutable<ZMap_Any>().Mutable(iName); - } + { return this->Mutable<ZMap_Any>().Mutable(iName); } ZVal_Any* ZVal_Any::PGetMutable(size_t iIndex) { Modified: trunk/zoolib/source/cxx/zoolib/ZVal_Any.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_Any.h 2012-01-30 12:16:24 UTC (rev 2700) +++ trunk/zoolib/source/cxx/zoolib/ZVal_Any.h 2012-01-30 12:16:55 UTC (rev 2701) @@ -504,6 +504,19 @@ // Our protocol ZVal_Any& Mutable(const string8& iName); + + template <class S> + S& Mutable(const string8& iName) + { return this->Mutable(iName).Mutable<S>(); } + + template <class S> + S& DMutable(const S& iDefault, const string8& iName) + { + if (S* theVal = this->PGetMutable<S>(iName)) + return *theVal; + this->Set(iName, iDefault); + return *this->PGetMutable<S>(iName); + } Index_t Begin() const; Index_t End() const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |