llvm.org GIT mirror llvm / 8f559ef
Modified Deserializer::ReadCStr to allow C-strings to be read into a std::vector<char> starting from any index in the vector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45129 91177308-0d34-0410-b5e6-96231b3b80d8 Ted Kremenek 12 years ago
2 changed file(s) with 11 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
155155 }
156156
157157 char* ReadCStr(char* cstr = NULL, unsigned MaxLen=0, bool isNullTerm=true);
158 void ReadCStr(std::vector& buff, bool isNullTerm=false);
158 void ReadCStr(std::vector& buff, bool isNullTerm=false, unsigned Idx=0);
159159
160160 template
161161 inline T* ReadOwnedPtr(bool AutoRegister = true) {
328328 return cstr;
329329 }
330330
331 void Deserializer::ReadCStr(std::vector& buff, bool isNullTerm) {
331 void Deserializer::ReadCStr(std::vector& buff, bool isNullTerm,
332 unsigned Idx) {
333
332334 unsigned len = ReadInt();
333335
334 buff.clear();
335 buff.reserve(len);
336 // If Idx is beyond the current before size, reduce Idx to refer to the
337 // element after the last element.
338 if (Idx > buff.size())
339 Idx = buff.size();
340
341 buff.reserve(len+Idx);
342 buff.resize(Idx);
336343
337344 for (unsigned i = 0; i < len; ++i)
338345 buff.push_back((char) ReadInt());