userver: userver/dump/unsafe.hpp Source File
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
unsafe.hpp
1#pragma once
2
3#include <string_view>
4
5#include <userver/dump/operations.hpp>
6
7USERVER_NAMESPACE_BEGIN
8
9namespace dump {
10
11/// @brief Writes a non-size-prefixed `std::string_view`
12/// @note `writer.Write(str)` should normally be used instead to write strings
13void WriteStringViewUnsafe(Writer& writer, std::string_view value);
14
15/// @brief Reads a `std::string_view`
16/// @warning The `string_view` will be invalidated on the next `Read` operation
18
19/// @brief Reads a non-size-prefixed `std::string_view`
20/// @note The caller must somehow know the string size in advance
21/// @warning The `string_view` will be invalidated on the next `Read` operation
23
24/// @brief Reads a `std::string_view`
25/// @note Normally, exactly `max_size` bytes is returned. On end-of-file,
26/// the amount of bytes returned can be less than `max_size`.
27/// @warning The `string_view` will be invalidated on the next `Read` operation
29
30/// @brief Moves the internal cursor back by `size` bytes
31/// so that the next call to @ref ReadUnsafeAtMost returns the same data again
32/// @note If there has been no previous call to @ref ReadUnsafeAtMost,
33/// or the last read operation was performed using something except
34/// @ref ReadUnsafeAtMost,
35/// or `size` is greater than the number of bytes returned,
36/// then the behavior is undefined.
37void BackUpReadUnsafe(Reader& reader, std::size_t size);
38
39} // namespace dump
40
41USERVER_NAMESPACE_END