mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-29 11:10:40 +00:00
util: Add bytes version of serialize_string
This commit is contained in:
@@ -219,6 +219,20 @@ void serialize_string(std::ostream& out, const sstring& s) {
|
||||
out.write(s.c_str(), s.size());
|
||||
}
|
||||
|
||||
inline
|
||||
void serialize_string(bytes::iterator& out, const sstring& s) {
|
||||
for (char c : s) {
|
||||
if (c == '\0') {
|
||||
throw UTFDataFormatException();
|
||||
}
|
||||
}
|
||||
if (s.size() > std::numeric_limits<uint16_t>::max()) {
|
||||
throw UTFDataFormatException();
|
||||
}
|
||||
serialize_int16(out, (uint16_t) s.size());
|
||||
out = std::copy(s.begin(), s.end(), out);
|
||||
}
|
||||
|
||||
inline
|
||||
size_t serialize_string_size(const sstring& s) {;
|
||||
// As above, this code is missing the case of modified utf-8
|
||||
|
||||
Reference in New Issue
Block a user