X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fbuilder%2Fdictionary.h;h=88095eb0dc713a000a6ecb25a994bcafba987934;hp=ccccf2c8d07d6a85dc1beee46ffef7c5e7f0c02f;hb=a827febe27e8131e681c24c255472bbbf097905f;hpb=1e86d6f1a754a11410f1d5b89a4520757cb53ff5 diff --git a/dali-toolkit/internal/builder/dictionary.h b/dali-toolkit/internal/builder/dictionary.h index ccccf2c..88095eb 100644 --- a/dali-toolkit/internal/builder/dictionary.h +++ b/dali-toolkit/internal/builder/dictionary.h @@ -36,6 +36,23 @@ namespace Internal * * It enables lookup of keys via case-insensitive match. */ + + +typedef std::vector DictionaryKeys; +inline void Merge( DictionaryKeys& toDict, const DictionaryKeys& fromDict ) +{ + for( DictionaryKeys::const_iterator fromIter = fromDict.begin(); fromIter != fromDict.end(); ++fromIter ) + { + const std::string& fromKey = (*fromIter); + DictionaryKeys::iterator toIter = std::find( toDict.begin(), toDict.end(), fromKey ); + if( toIter == toDict.end() ) + { + toDict.push_back( fromKey ); + } + } +} + + template class Dictionary { @@ -62,7 +79,6 @@ public: */ typedef typename Elements::const_iterator iterator; - /** * Constructor */ @@ -105,6 +121,53 @@ public: } /** + * Remove a key value pair from the dictionary. + */ + void Remove( const std::string& name ) + { + for( typename Elements::iterator iter = container.begin(); iter != container.end(); ++iter ) + { + if( iter->key == name ) + { + container.erase( iter ); + break; + } + } + } + + /** + * Remove a key value pair from the dictionary. + */ + void Remove( const char* name ) + { + if( name != NULL ) + { + std::string theName(name); + Remove(theName); + } + } + + void Merge( const Dictionary& dictionary ) + { + for( typename Elements::const_iterator fromIter = dictionary.container.begin(); fromIter != dictionary.container.end(); ++fromIter ) + { + bool found=false; + for( typename Elements::iterator toIter = container.begin(); toIter != container.end(); ++toIter ) + { + if( fromIter->key == toIter->key ) + { + found=true; + toIter->entry = fromIter->entry; + } + } + if( !found ) + { + container.push_back( Element(fromIter->key, fromIter->entry) ); + } + } + } + + /** * Find the element in the dictionary pointed at by key, and * insensitive search, and return a const pointer to it, or NULL */ @@ -187,6 +250,20 @@ public: { return container.end(); } + + void GetKeys( DictionaryKeys& keys ) const + { + keys.clear(); + for( typename Elements::const_iterator iter = container.begin(); iter != container.end(); ++iter ) + { + keys.push_back( (*iter).key ); + } + } + + void Clear() + { + container.clear(); + } };