Serializer improvements:

* Add getSlice()
* Make getVLDataLength public
This commit is contained in:
Vinnie Falco
2015-06-29 14:01:31 -07:00
parent bd7eb94d69
commit cb791482a0
2 changed files with 22 additions and 3 deletions

View File

@@ -353,6 +353,15 @@ public:
void
getFieldID (int& type, int& name);
// Returns the size of the VL if the
// next object is a VL. Advances the iterator
// to the beginning of the VL.
int
getVLDataLength ();
Slice
getSlice (std::size_t bytes);
// VFALCO DEPRECATED Returns a copy
Blob
getRaw (int size);
@@ -364,9 +373,6 @@ public:
Buffer
getVLBuffer();
private:
int getVLDataLength ();
template<class T>
T getRawHelper (int size);
};

View File

@@ -575,6 +575,19 @@ int SerialIter::getVLDataLength ()
return datLen;
}
Slice
SerialIter::getSlice (std::size_t bytes)
{
if (bytes > remain_)
throw std::runtime_error(
"invalid SerialIter getSlice");
Slice s(p_, bytes);
p_ += bytes;
used_ += bytes;
remain_ -= bytes;
return s;
}
// VFALCO DEPRECATED Returns a copy
Blob
SerialIter::getVL()