simdjson  3.1.6
Ridiculously Fast JSON
padded_string_view.h
1 #ifndef SIMDJSON_PADDED_STRING_VIEW_H
2 #define SIMDJSON_PADDED_STRING_VIEW_H
3 
4 #include "simdjson/portability.h"
5 #include "simdjson/common_defs.h" // for SIMDJSON_PADDING
6 #include "simdjson/error.h"
7 
8 #include <cstring>
9 #include <memory>
10 #include <string>
11 #include <ostream>
12 
13 namespace simdjson {
14 
18 class padded_string_view : public std::string_view {
19 private:
20  size_t _capacity;
21 
22 public:
24  inline padded_string_view() noexcept = default;
25 
33  explicit inline padded_string_view(const char* s, size_t len, size_t capacity) noexcept;
35  explicit inline padded_string_view(const uint8_t* s, size_t len, size_t capacity) noexcept;
36 
44  explicit inline padded_string_view(const std::string &s) noexcept;
45 
52  explicit inline padded_string_view(std::string_view s, size_t capacity) noexcept;
53 
55  inline size_t capacity() const noexcept;
56 
58  inline size_t padding() const noexcept;
59 
60 }; // padded_string_view
61 
62 #if SIMDJSON_EXCEPTIONS
72 inline std::ostream& operator<<(std::ostream& out, simdjson_result<padded_string_view> &s) noexcept(false) { return out << s.value(); }
73 #endif
74 
75 } // namespace simdjson
76 
77 #endif // SIMDJSON_PADDED_STRING_VIEW_H
User-provided string that promises it has extra padded bytes at the end for use with parser::parse().
size_t padding() const noexcept
The amount of padding on the string (capacity() - length())
size_t capacity() const noexcept
The number of allocated bytes.
padded_string_view() noexcept=default
Create an empty padded_string_view.
We want to support argument-dependent lookup (ADL).
std::ostream & operator<<(std::ostream &out, error_code error) noexcept
Write the error message to the output stream.
Definition: error-inl.h:36
The result of a simdjson operation that could fail.
Definition: error.h:205