1 /* 2 Copyright (C) 2005-2007 Feeling Software Inc. 3 Portions of the code are: 4 Copyright (C) 2005-2007 Sony Computer Entertainment America 5 6 MIT License: http://www.opensource.org/licenses/mit-license.php 7 */ 8 9 /** 10 @file FUUniqueStringMap.h 11 This file contains the FUUniqueStringMapT template. 12 */ 13 14 #ifndef _FU_UNIQUE_ID_MAP_H_ 15 #define _FU_UNIQUE_ID_MAP_H_ 16 17 /** 18 A set of unique strings. 19 This class adds three functions to the STL map in order to 20 keep the strings inside unique: AddUniqueString, Exists and Erase. 21 22 @ingroup FUtils 23 */ 24 template <class CH> 25 class FCOLLADA_EXPORT FUUniqueStringMapT 26 { 27 private: 28 typedef fm::map<uint32, uint32> NumberMap; // This is really a set and the second uint32 is not used. 29 typedef fm::map<fm::stringT<CH>, NumberMap> StringMap; 30 31 StringMap values; 32 33 public: 34 /** Adds a string to the map. 35 If the string isn't unique, it will be modified in order to make it unique. 36 @param wantedStr The string to add. This reference will be directly 37 modified to hold the actual unique string added to the map. */ 38 void insert(fm::stringT<CH>& wantedStr); insert(const fm::stringT<CH> & wantedStr)39 void insert(const fm::stringT<CH>& wantedStr) { fm::stringT<CH> a = wantedStr; insert(a); } /**< See above. */ 40 41 /** Retrieves whether a given string is contained within the map. 42 @param str The string. */ 43 bool contains(const fm::stringT<CH>& str) const; 44 45 /** Erases a string from the map. 46 @param str A string contained within the map. */ 47 void erase(const fm::stringT<CH>& str); 48 }; 49 50 typedef FUUniqueStringMapT<char> FUSUniqueStringMap; /**< A map of unique UTF-8 strings. */ 51 typedef FUUniqueStringMapT<fchar> FUUniqueStringMap; /**< A map of unique Unicode strings. */ 52 53 #endif // _FU_UNIQUE_ID_MAP_H_ 54 55