MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / AddStringSet

Method AddStringSet

src/core/userstringmem.cpp:115–144  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

113// around for as long as this class uses them. A static array defined at
114// compile time is perfect for this.
115void 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
146void cUserStringMemBased::AddString(int setID, int stringID, TCHAR* string)
147{

Callers

nothing calls this directly

Calls 3

endMethod · 0.80
beginMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected