21 static std::string
const header =
"_Subscri";
22 static std::string
const mode =
" w ";
23 static std::string
const trailer =
"_Always";
25 uint32_t
const tagsize = ntohl(3 + tag.size());
27 std::size_t
const total_size
36 if (total_size > max_size) {
37 throw std::runtime_error(
"buffer too small");
40 std::memset(buffer,
'\0', total_size);
42 std::memcpy(buffer, header.c_str(), header.size());
43 buffer += header.size();
44 std::memcpy(buffer, &tagsize,
sizeof(tagsize));
45 buffer +=
sizeof(tagsize);
47 std::memcpy(buffer, mode.c_str(), mode.size());
48 buffer += mode.size();
49 std::memcpy(buffer, tag.c_str(), tag.size());
51 std::memcpy(buffer, trailer.c_str(), trailer.size());