Changeset View
Changeset View
Standalone View
Standalone View
src/streams.h
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
class CVectorWriter { | class CVectorWriter { | ||||
public: | public: | ||||
/** | /** | ||||
* @param[in] nTypeIn Serialization Type | * @param[in] nTypeIn Serialization Type | ||||
* @param[in] nVersionIn Serialization Version (including any flags) | * @param[in] nVersionIn Serialization Version (including any flags) | ||||
* @param[in] vchDataIn Referenced byte vector to overwrite/append | * @param[in] vchDataIn Referenced byte vector to overwrite/append | ||||
* @param[in] nPosIn Starting position. Vector index where writes should | * @param[in] nPosIn Starting position. Vector index where writes should | ||||
* start. The vector will initially grow as necessary to max(index, | * start. The vector will initially grow as necessary to max(nPosIn, | ||||
* vec.size()). So to append, use vec.size(). | * vec.size()). So to append, use vec.size(). | ||||
*/ | */ | ||||
CVectorWriter(int nTypeIn, int nVersionIn, std::vector<uint8_t> &vchDataIn, | CVectorWriter(int nTypeIn, int nVersionIn, std::vector<uint8_t> &vchDataIn, | ||||
size_t nPosIn) | size_t nPosIn) | ||||
: nType(nTypeIn), nVersion(nVersionIn), vchData(vchDataIn), | : nType(nTypeIn), nVersion(nVersionIn), vchData(vchDataIn), | ||||
nPos(nPosIn) { | nPos(nPosIn) { | ||||
if (nPos > vchData.size()) vchData.resize(nPos); | if (nPos > vchData.size()) vchData.resize(nPos); | ||||
} | } | ||||
/** | /** | ||||
* (other params same as above) | * (other params same as above) | ||||
* @param[in] args A list of items to serialize starting at nPos. | * @param[in] args A list of items to serialize starting at nPosIn. | ||||
*/ | */ | ||||
template <typename... Args> | template <typename... Args> | ||||
CVectorWriter(int nTypeIn, int nVersionIn, std::vector<uint8_t> &vchDataIn, | CVectorWriter(int nTypeIn, int nVersionIn, std::vector<uint8_t> &vchDataIn, | ||||
size_t nPosIn, Args &&... args) | size_t nPosIn, Args &&... args) | ||||
: CVectorWriter(nTypeIn, nVersionIn, vchDataIn, nPosIn) { | : CVectorWriter(nTypeIn, nVersionIn, vchDataIn, nPosIn) { | ||||
::SerializeMany(*this, std::forward<Args>(args)...); | ::SerializeMany(*this, std::forward<Args>(args)...); | ||||
} | } | ||||
void write(const char *pch, size_t nSize) { | void write(const char *pch, size_t nSize) { | ||||
▲ Show 20 Lines • Show All 730 Lines • Show Last 20 Lines |