Add an array of string pairs to a string set. The pair array passed in should terminate with an id of -1. If this string set contains string IDs that already exist in the string set, they will "overwrite" the the previous strings. Note: We store only pointers to the string pairs so they must remain around for as long as this class uses them. A static array defined at compile time is perfect for
| 113 | // around for as long as this class uses them. A static array defined at |
| 114 | // compile time is perfect for this. |
| 115 | void cUserStringMemBased::AddStringSet(int setID, const iUserString::tStringPair* pPairArray) |
| 116 | { |
| 117 | std::map<int, StringSet*>::const_iterator setItr; |
| 118 | |
| 119 | setItr = mStringSets.find(setID); |
| 120 | if (setItr == mStringSets.end()) |
| 121 | { |
| 122 | // first time we have seen this setID |
| 123 | setItr = mStringSets.insert(mStringSets.begin(), std::pair<int, StringSet*>(setID, new StringSet)); |
| 124 | } |
| 125 | |
| 126 | ASSERT(pPairArray); |
| 127 | while (pPairArray->id >= 0) |
| 128 | { |
| 129 | StringSet::iterator stringItr; |
| 130 | |
| 131 | ASSERT(setItr->second); |
| 132 | stringItr = setItr->second->find(pPairArray->id); |
| 133 | if (stringItr != setItr->second->end()) |
| 134 | { |
| 135 | // Already a string of for this ID, |
| 136 | // so lets replace it! |
| 137 | setItr->second->erase(stringItr); |
| 138 | } |
| 139 | |
| 140 | setItr->second->insert(std::pair<int, TCHAR*>(pPairArray->id, pPairArray->string)); |
| 141 | |
| 142 | pPairArray++; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | void cUserStringMemBased::AddString(int setID, int stringID, TCHAR* string) |
| 147 | { |