proxygen
fizz::detail::ReadVector< N, T > Struct Template Reference

#include <Types-inl.h>

Public Member Functions

size_t readVector (std::vector< T > &out, folly::io::Cursor &cursor)
 

Detailed Description

template<class N, class T>
struct fizz::detail::ReadVector< N, T >

Definition at line 263 of file Types-inl.h.

Member Function Documentation

template<class N , class T >
size_t fizz::detail::ReadVector< N, T >::readVector ( std::vector< T > &  out,
folly::io::Cursor cursor 
)
inline

Definition at line 264 of file Types-inl.h.

References fizz::detail::read(), folly::io::detail::CursorBase< Derived, BufType >::readBE(), T, and folly::io::detail::CursorBase< Derived, BufType >::totalLength().

264  {
265  auto len = cursor.readBE<N>();
266  if (cursor.totalLength() < len) {
267  throw std::out_of_range("Not enough data");
268  }
269 
270  size_t consumed = 0;
271  while (consumed < len) {
272  out.push_back(T());
273  consumed += read(*out.rbegin(), cursor);
274  }
275  if (consumed != len) {
276  throw std::runtime_error("Invalid data length supplied");
277  }
278  return len + sizeof(N);
279  }
#define T(v)
Definition: http_parser.c:233
size_t read(T &out, folly::io::Cursor &cursor)
Definition: Types-inl.h:258
size_t totalLength() const
Definition: Cursor.h:126

The documentation for this struct was generated from the following file: