1#ifndef SIMDJSON_PADDED_STRING_VIEW_INL_H
2#define SIMDJSON_PADDED_STRING_VIEW_INL_H
4#include "simdjson/padded_string_view.h"
5#include "simdjson/error-inl.h"
12 : std::string_view(s, len), _capacity(capacity)
14 if(_capacity < len) { _capacity = len; }
28 : std::string_view(s), _capacity(s.capacity())
33 : std::string_view(s), _capacity(capacity)
35 if(_capacity < s.length()) { _capacity = s.length(); }
43 if(length() < missing_padding) {
return false; }
45 for (
size_t i = length() - missing_padding; i < length(); i++) {
47 if (c !=
' ' && c !=
'\t' && c !=
'\n' && c !=
'\r') {
59 if(length() < 3) {
return false; }
60 if (std::memcmp(data(),
"\xEF\xBB\xBF", 3) == 0) {
68#if SIMDJSON_EXCEPTIONS
73 size_t existing_padding = 0;
74 for (
size_t i = s.size(); i > 0; i--) {
76 if (c ==
' ' || c ==
'\t' || c ==
'\n' || c ==
'\r') {
82 size_t needed_padding = 0;
85 s.append(needed_padding,
' ');
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.
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.
constexpr size_t SIMDJSON_PADDING
The amount of padding needed in a buffer to parse JSON.
The result of a simdjson operation that could fail.