25#include <seastar/core/sstring.hh>
26#include <seastar/core/temporary_buffer.hh>
27#include <seastar/util/eclipse.hh>
32#include <seastar/util/modules.hh>
33#include <seastar/core/future.hh>
54 const char* _start =
nullptr;
59 return std::move(_value);
70 const char* _block_end;
73 : _builder(builder), _block_end(block_end) {
74 if (!_builder._value.empty()) {
75 mark_start(block_start);
79 if (_builder._start) {
83 void mark_start(
const char* p) {
86 void mark_end(
const char* p) {
87 if (_builder._value.empty()) {
89 _builder._value = sstring(_builder._start, p);
91 _builder._value += sstring(_builder._start, p);
93 _builder._start =
nullptr;
97SEASTAR_MODULE_EXPORT_BEGIN
100template <
typename ConcreteParser>
104 std::unique_ptr<int[]> _fsm_stack =
nullptr;
105 int _fsm_stack_size = 0;
116 if (_fsm_top == _fsm_stack_size) {
117 auto old = _fsm_stack_size;
118 _fsm_stack_size = std::max(_fsm_stack_size * 2, 16);
119 assert(_fsm_stack_size > old);
120 std::unique_ptr<int[]> new_stack{
new int[_fsm_stack_size]};
121 std::copy(_fsm_stack.get(), _fsm_stack.get() + _fsm_top, new_stack.get());
122 std::swap(_fsm_stack, new_stack);
127 return std::move(_builder).get();
130 using unconsumed_remainder = std::optional<temporary_buffer<char>>;
133 char* pe = p + buf.
size();
134 char* eof = buf.
empty() ? pe :
nullptr;
135 char* parsed =
static_cast<ConcreteParser*
>(
this)->parse(p, pe, eof);
138 return make_ready_future<unconsumed_remainder>(std::move(buf));
140 return make_ready_future<unconsumed_remainder>();
144inline void trim_trailing_spaces_and_tabs(sstring& str) {
145 auto data = str.data();
147 for (i = str.size(); i > 0; --i) {
149 if (!(c ==
' ' || c ==
'\t')) {
155SEASTAR_MODULE_EXPORT_END
A representation of a possibly not-yet-computed value.
Definition: future.hh:1240
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