// CLASS HEADER
#include <dali/public-api/object/property-map.h>
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
// INTERNAL INCLUDES
#include <dali/public-api/common/vector-wrapper.h>
}; // unnamed namespace
+
struct Property::Map::Impl
{
StringValueContainer mStringValueContainer;
Property::Value& Property::Map::GetValue( SizeType position ) const
{
- DALI_ASSERT_ALWAYS( position < mImpl->mStringValueContainer.size() && "position out-of-bounds" );
+ SizeType numStringKeys = mImpl->mStringValueContainer.size();
+ SizeType numIndexKeys = mImpl->mIndexValueContainer.size();
+ DALI_ASSERT_ALWAYS( position < ( numStringKeys + numIndexKeys ) && "position out-of-bounds" );
- return mImpl->mStringValueContainer[ position ].second;
+ if( position < numStringKeys )
+ {
+ return mImpl->mStringValueContainer[ position ].second;
+ }
+ else
+ {
+ return mImpl->mIndexValueContainer[ position-numStringKeys ].second;
+ }
}
const std::string& Property::Map::GetKey( SizeType position ) const
{
- DALI_ASSERT_ALWAYS( position < mImpl->mStringValueContainer.size() && "position out-of-bounds" );
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetKey() is deprecated and will be removed from next release.\n" );
+
+ SizeType numStringKeys = mImpl->mStringValueContainer.size();
+ DALI_ASSERT_ALWAYS( position < numStringKeys && "position out-of-bounds" );
return mImpl->mStringValueContainer[ position ].first;
}
+Property::Key Property::Map::GetKeyAt( SizeType position ) const
+{
+ SizeType numStringKeys = mImpl->mStringValueContainer.size();
+ SizeType numIndexKeys = mImpl->mIndexValueContainer.size();
+ DALI_ASSERT_ALWAYS( position < ( numStringKeys + numIndexKeys ) && "position out-of-bounds" );
+
+ if( position < numStringKeys )
+ {
+ Key key(mImpl->mStringValueContainer[ position ].first);
+ return key;
+ }
+ else
+ {
+ Key key( mImpl->mIndexValueContainer[ position-numStringKeys ].first );
+ return key;
+ }
+}
+
StringValuePair& Property::Map::GetPair( SizeType position ) const
{
- DALI_ASSERT_ALWAYS( position < mImpl->mStringValueContainer.size() && "position out-of-bounds" );
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetPair() is deprecated and will be removed from next release.\n" );
+
+ SizeType numStringKeys = mImpl->mStringValueContainer.size();
+
+ DALI_ASSERT_ALWAYS( position < ( numStringKeys ) && "position out-of-bounds" );
return mImpl->mStringValueContainer[ position ];
}
+KeyValuePair Property::Map::GetKeyValue( SizeType position ) const
+{
+ SizeType numStringKeys = mImpl->mStringValueContainer.size();
+ SizeType numIndexKeys = mImpl->mIndexValueContainer.size();
+
+ DALI_ASSERT_ALWAYS( position < ( numStringKeys + numIndexKeys ) && "position out-of-bounds" );
+
+ if( position < numStringKeys )
+ {
+ Key key(mImpl->mStringValueContainer[ position ].first);
+ KeyValuePair keyValue(key, mImpl->mStringValueContainer[ position ].second );
+ return keyValue;
+ }
+ else
+ {
+ Key key( mImpl->mIndexValueContainer[ position-numStringKeys ].first );
+ KeyValuePair keyValue(key, mImpl->mIndexValueContainer[ position-numStringKeys ].second );
+ return keyValue;
+ }
+}
+
Property::Value* Property::Map::Find( const char* key ) const
{
for ( StringValueContainer::iterator iter = mImpl->mStringValueContainer.begin(), endIter = mImpl->mStringValueContainer.end(); iter != endIter; ++iter )
return NULL; // Not found
}
+Property::Value* Property::Map::Find( Property::Index indexKey, const std::string& stringKey ) const
+{
+ Property::Value* valuePtr = Find( indexKey );
+ if( !valuePtr )
+ {
+ valuePtr = Find( stringKey );
+ }
+ return valuePtr;
+}
+
Property::Value* Property::Map::Find( const std::string& key, Property::Type type ) const
{
for ( StringValueContainer::iterator iter = mImpl->mStringValueContainer.begin(), endIter = mImpl->mStringValueContainer.end(); iter != endIter; ++iter )