25#include <seastar/core/sstring.hh>
26#include <seastar/core/temporary_buffer.hh>
27#include <seastar/util/assert.hh>
28#include <seastar/util/eclipse.hh>
33#include <seastar/util/modules.hh>
34#include <seastar/core/future.hh>
55 const char* _start =
nullptr;
60 return std::move(_value);
71 const char* _block_end;
74 : _builder(builder), _block_end(block_end) {
75 if (!_builder._value.empty()) {
76 mark_start(block_start);
80 if (_builder._start) {
84 void mark_start(
const char* p) {
87 void mark_end(
const char* p) {
88 if (_builder._value.empty()) {
90 _builder._value = sstring(_builder._start, p);
92 _builder._value += sstring(_builder._start, p);
94 _builder._start =
nullptr;
98SEASTAR_MODULE_EXPORT_BEGIN
101template <
typename ConcreteParser>
105 std::unique_ptr<int[]> _fsm_stack =
nullptr;
106 int _fsm_stack_size = 0;
117 if (_fsm_top == _fsm_stack_size) {
118 auto old = _fsm_stack_size;
119 _fsm_stack_size = std::max(_fsm_stack_size * 2, 16);
120 SEASTAR_ASSERT(_fsm_stack_size > old);
121 std::unique_ptr<int[]> new_stack{
new int[_fsm_stack_size]};
122 std::copy(_fsm_stack.get(), _fsm_stack.get() + _fsm_top, new_stack.get());
123 std::swap(_fsm_stack, new_stack);
128 return std::move(_builder).get();
131 using unconsumed_remainder = std::optional<temporary_buffer<char>>;
134 char* pe = p + buf.
size();
135 char* eof = buf.
empty() ? pe :
nullptr;
136 char* parsed =
static_cast<ConcreteParser*
>(
this)->parse(p, pe, eof);
139 return make_ready_future<unconsumed_remainder>(std::move(buf));
141 return make_ready_future<unconsumed_remainder>();
145inline void trim_trailing_spaces_and_tabs(sstring& str) {
146 auto data = str.data();
148 for (i = str.size(); i > 0; --i) {
150 if (!(c ==
' ' || c ==
'\t')) {
156SEASTAR_MODULE_EXPORT_END
A representation of a possibly not-yet-computed value.
Definition: future.hh:1197
bool empty() const noexcept
Checks whether the buffer is empty.
Definition: temporary_buffer.hh:152
void trim_front(size_t pos) noexcept
Definition: temporary_buffer.hh:186
size_t size() const noexcept
Gets the buffer size.
Definition: temporary_buffer.hh:130
CharType * get_write() noexcept
Definition: temporary_buffer.hh:128
Seastar API namespace.
Definition: abort_on_ebadf.hh:26