pstore2
Static Public Member Functions | List of all members
pstore::serialize::string_helper Struct Reference

Static Public Member Functions

template<typename Archive , typename StringType >
static auto write (Archive &&archive, StringType const &str) -> archive_result_type< Archive >
 Writes an instance of a string type (e.g. More...
 
template<typename Archive >
static std::size_t read_length (Archive &&archive)
 

Member Function Documentation

◆ write()

template<typename Archive , typename StringType >
static auto pstore::serialize::string_helper::write ( Archive &&  archive,
StringType const &  str 
) -> archive_result_type<Archive>
inlinestatic

Writes an instance of a string type (e.g.

sstring_view) to an archive.

Writes a variable length value followed by a sequence of characters. The length uses the format defined by varint::encode() but we ensure that at least two bytes are produced. This means that the read() member can rely on being able to read two bytes and reduce the number of pstore accesses to two for strings < (2^14 - 1) characters (and three for strings longer than that.

Parameters
archiveThe Archiver to which the value 'str' should be written.
strThe string whose content is to be written to the archive.
Returns
The value returned by writing the first byte of the string length. By convention, this is the "address" of the string data (although the precise meaning is determined by the archive type).

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