+bool Builder::ConvertChildValue( const TreeNode& mappingRoot, KeyStack& keyStack, Property::Value& child )
+{
+ bool result = false;
+
+ switch( child.GetType() )
+ {
+ case Property::STRING:
+ {
+ std::string value;
+ if( child.Get( value ) )
+ {
+ std::string key;
+ if( GetMappingKey( value, key ) )
+ {
+ // Check key for cycles:
+ result=true;
+ for( KeyStack::iterator iter = keyStack.begin() ; iter != keyStack.end(); ++iter )
+ {
+ if( key.compare(*iter) == 0 )
+ {
+ // key is already in stack; stop.
+ DALI_LOG_WARNING("Detected cycle in stylesheet mapping table:%s\n", key.c_str());
+ child = Property::Value("");
+ result=false;
+ break;
+ }
+ }
+
+ if( result )
+ {
+ // The following call will overwrite the child with the value
+ // from the mapping.
+ RecursePropertyMap( mappingRoot, keyStack, key.c_str(), Property::NONE, child );
+ result = true;
+ }
+ }
+ }
+ break;
+ }
+
+ case Property::MAP:
+ {
+ Property::Map* map = child.GetMap();
+ for( Property::Map::SizeType i=0; i < map->Count(); ++i )
+ {
+ Property::Value& child = map->GetValue(i);
+ ConvertChildValue(mappingRoot, keyStack, child);
+ }
+ break;
+ }
+
+ case Property::ARRAY:
+ {
+ Property::Array* array = child.GetArray();
+ for( Property::Array::SizeType i=0; i < array->Count(); ++i )
+ {
+ Property::Value& child = array->GetElementAt(i);
+ ConvertChildValue(mappingRoot, keyStack, child);
+ }
+ break;
+ }
+
+ default:
+ // Ignore other types.
+ break;
+ }
+
+ return result;
+}
+
+bool Builder::RecursePropertyMap( const TreeNode& mappingRoot, KeyStack& keyStack, const char* theKey, Property::Type propertyType, Property::Value& value )
+{
+ Replacement replacer( mReplacementMap );
+ bool result = false;
+
+ keyStack.push_back( theKey );
+
+ for( TreeNode::ConstIterator iter = mappingRoot.CBegin(); iter != mappingRoot.CEnd(); ++iter )
+ {
+ std::string aKey( (*iter).first );
+ if( aKey.compare( theKey ) == 0 )
+ {
+ if( propertyType == Property::NONE )
+ {
+ DeterminePropertyFromNode( (*iter).second, value, replacer );
+ result = true;
+ }
+ else
+ {
+ result = DeterminePropertyFromNode( (*iter).second, propertyType, value, replacer );
+ }
+
+ if( result )
+ {
+ ConvertChildValue(mappingRoot, keyStack, value);
+ }
+ break;
+ }
+ }
+ keyStack.pop_back();
+
+ return result;
+}
+
+
+bool Builder::GetPropertyMap( const TreeNode& mappingRoot, const char* theKey, Property::Type propertyType, Property::Value& value )
+{
+ KeyStack keyStack;
+ return RecursePropertyMap( mappingRoot, keyStack, theKey, propertyType, value );
+}
+
+