simdjson 4.2.0
Ridiculously Fast JSON
Loading...
Searching...
No Matches
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/base.h" // for SIMDJSON_PADDING
6#include "simdjson/error.h"
7
8#include <cstring>
9#include <memory>
10#include <string>
11#include <ostream>
12
13namespace simdjson {
14
18class padded_string_view : public std::string_view {
19private:
20 size_t _capacity;
21
22public:
24 inline padded_string_view() noexcept = default;
25
34 explicit inline padded_string_view(const char* s, size_t len, size_t capacity) noexcept;
36 explicit inline padded_string_view(const uint8_t* s, size_t len, size_t capacity) noexcept;
37#ifdef __cpp_char8_t
38 explicit inline padded_string_view(const char8_t* s, size_t len, size_t capacity) noexcept;
39#endif
47 explicit inline padded_string_view(const std::string &s) noexcept;
48
56 explicit inline padded_string_view(std::string_view s, size_t capacity) noexcept;
57
59 inline size_t capacity() const noexcept;
60
62 inline bool has_sufficient_padding() const noexcept;
63
69 inline bool remove_utf8_bom() noexcept;
70
72 inline size_t padding() const noexcept;
73
74}; // padded_string_view
75
76#if SIMDJSON_EXCEPTIONS
86inline std::ostream& operator<<(std::ostream& out, simdjson_result<padded_string_view> &s) noexcept(false);
87#endif
88
97inline padded_string_view pad(std::string& s) noexcept;
98
107inline padded_string_view pad_with_reserve(std::string& s) noexcept;
108} // namespace simdjson
109
110#endif // SIMDJSON_PADDED_STRING_VIEW_H
User-provided string that promises it has extra padded bytes at the end for use with parser::parse().
bool remove_utf8_bom() noexcept
Remove the UTF-8 Byte Order Mark (BOM) if it exists.
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.
bool has_sufficient_padding() const noexcept
check that the view has sufficient padding
The top level simdjson namespace, containing everything the library provides.
Definition base.h:8
padded_string_view pad_with_reserve(std::string &s) noexcept
Create a padded_string_view from a string.
padded_string_view pad(std::string &s) noexcept
Create a padded_string_view from a string.
The result of a simdjson operation that could fail.
Definition error.h:278