static Block makeBlock(uint32_t type, Iterator first, Iterator last) { EncodingEstimator estimator; size_t valueLength = last - first; size_t totalLength = valueLength; totalLength += estimator.prependVarNumber(valueLength); totalLength += estimator.prependVarNumber(type); EncodingBuffer encoder(totalLength, 0); encoder.prependRange(first, last); encoder.prependVarNumber(valueLength); encoder.prependVarNumber(type); return encoder.block(); }
Component Component::fromNumberWithMarker(uint8_t marker, uint64_t number) { EncodingEstimator estimator; size_t valueLength = estimator.prependNonNegativeInteger(number); valueLength += estimator.prependByteArray(&marker, 1); size_t totalLength = valueLength; totalLength += estimator.prependVarNumber(valueLength); totalLength += estimator.prependVarNumber(tlv::GenericNameComponent); EncodingBuffer encoder(totalLength, 0); encoder.prependNonNegativeInteger(number); encoder.prependByteArray(&marker, 1); encoder.prependVarNumber(valueLength); encoder.prependVarNumber(tlv::GenericNameComponent); return encoder.block(); }