rapidyaml 0.15.2
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
c4::yml::FilterProcessorSrcDst Struct Reference

Filters an input string into a different output string. More...

#include <filter_processor.hpp>

Public Member Functions

 FilterProcessorSrcDst (csubstr src_, substr dst_) noexcept
void setwpos (size_t wpos_) noexcept
void setpos (size_t rpos_, size_t wpos_) noexcept
void set_at_end () noexcept
bool has_more_chars () const noexcept
bool has_more_chars (size_t maxpos) const noexcept
csubstr rem () const noexcept
csubstr sofar () const noexcept
FilterResult result () const noexcept
char curr () const noexcept
char next () const noexcept
bool skipped_chars () const noexcept
void skip () noexcept
void skip (size_t num) noexcept
void set_at (size_t pos, char c) noexcept
void set (char c) noexcept
void set (char c, size_t num) noexcept
void copy () noexcept
void copy (size_t num) noexcept
void translate_esc (char c) noexcept
void translate_esc_bulk (const char *s, size_t nw, size_t nr) noexcept
void translate_esc_extending (const char *s, size_t nw, size_t nr) noexcept

Public Attributes

csubstr src
substr dst
size_t rpos
 read position
size_t wpos
 write position

Detailed Description

Filters an input string into a different output string.

Definition at line 48 of file filter_processor.hpp.

Constructor & Destructor Documentation

◆ FilterProcessorSrcDst()

c4::yml::FilterProcessorSrcDst::FilterProcessorSrcDst ( csubstr src_,
substr dst_ )
inlinenoexcept

Definition at line 55 of file filter_processor.hpp.

56 : src(src_)
57 , dst(dst_)
58 , rpos(0)
59 , wpos(0)
60 {
61 RYML_ASSERT_BASIC_(!dst.overlaps(src));
62 }

Member Function Documentation

◆ setwpos()

void c4::yml::FilterProcessorSrcDst::setwpos ( size_t wpos_)
inlinenoexcept

Definition at line 64 of file filter_processor.hpp.

64{ wpos = wpos_; }

◆ setpos()

void c4::yml::FilterProcessorSrcDst::setpos ( size_t rpos_,
size_t wpos_ )
inlinenoexcept

Definition at line 65 of file filter_processor.hpp.

65{ rpos = rpos_; wpos = wpos_; }

◆ set_at_end()

void c4::yml::FilterProcessorSrcDst::set_at_end ( )
inlinenoexcept

Definition at line 66 of file filter_processor.hpp.

66{ skip(src.len - rpos); }

◆ has_more_chars() [1/2]

bool c4::yml::FilterProcessorSrcDst::has_more_chars ( ) const
inlinenoexcept

Definition at line 68 of file filter_processor.hpp.

68{ return rpos < src.len; }

◆ has_more_chars() [2/2]

bool c4::yml::FilterProcessorSrcDst::has_more_chars ( size_t maxpos) const
inlinenoexcept

Definition at line 69 of file filter_processor.hpp.

69{ RYML_ASSERT_BASIC_(maxpos <= src.len); return rpos < maxpos; }

◆ rem()

csubstr c4::yml::FilterProcessorSrcDst::rem ( ) const
inlinenoexcept

Definition at line 71 of file filter_processor.hpp.

71{ return src.sub(rpos); }

◆ sofar()

csubstr c4::yml::FilterProcessorSrcDst::sofar ( ) const
inlinenoexcept

Definition at line 72 of file filter_processor.hpp.

72{ return csubstr(dst.str, wpos <= dst.len ? wpos : dst.len); }
basic_substring< const char > csubstr
an immutable string view
Definition substr.hpp:2356

◆ result()

FilterResult c4::yml::FilterProcessorSrcDst::result ( ) const
inlinenoexcept

Definition at line 73 of file filter_processor.hpp.

74 {
75 FilterResult ret;
76 ret.str.str = wpos <= dst.len ? dst.str : nullptr;
77 ret.str.len = wpos;
78 return ret;
79 }

◆ curr()

char c4::yml::FilterProcessorSrcDst::curr ( ) const
inlinenoexcept

Definition at line 81 of file filter_processor.hpp.

81{ RYML_ASSERT_BASIC_(rpos < src.len); return src[rpos]; }

◆ next()

char c4::yml::FilterProcessorSrcDst::next ( ) const
inlinenoexcept

Definition at line 82 of file filter_processor.hpp.

82{ return rpos+1 < src.len ? src[rpos+1] : '\0'; }

◆ skipped_chars()

bool c4::yml::FilterProcessorSrcDst::skipped_chars ( ) const
inlinenoexcept

Definition at line 83 of file filter_processor.hpp.

83{ return wpos != rpos; }

◆ skip() [1/2]

void c4::yml::FilterProcessorSrcDst::skip ( )
inlinenoexcept

Definition at line 85 of file filter_processor.hpp.

85{ ++rpos; }

Referenced by set_at_end().

◆ skip() [2/2]

void c4::yml::FilterProcessorSrcDst::skip ( size_t num)
inlinenoexcept

Definition at line 86 of file filter_processor.hpp.

86{ rpos += num; }

◆ set_at()

void c4::yml::FilterProcessorSrcDst::set_at ( size_t pos,
char c )
inlinenoexcept

Definition at line 88 of file filter_processor.hpp.

89 {
90 RYML_ASSERT_BASIC_(pos < wpos);
91 dst.str[pos] = c;
92 }

◆ set() [1/2]

void c4::yml::FilterProcessorSrcDst::set ( char c)
inlinenoexcept

Definition at line 93 of file filter_processor.hpp.

94 {
95 if(wpos < dst.len)
96 dst.str[wpos] = c;
97 ++wpos;
98 }

◆ set() [2/2]

void c4::yml::FilterProcessorSrcDst::set ( char c,
size_t num )
inlinenoexcept

Definition at line 99 of file filter_processor.hpp.

100 {
101 RYML_ASSERT_BASIC_(num > 0);
102 if(wpos + num <= dst.len)
103 memset(dst.str + wpos, c, num);
104 wpos += num;
105 }

◆ copy() [1/2]

void c4::yml::FilterProcessorSrcDst::copy ( )
inlinenoexcept

Definition at line 107 of file filter_processor.hpp.

108 {
109 RYML_ASSERT_BASIC_(rpos < src.len);
110 if(wpos < dst.len)
111 dst.str[wpos] = src.str[rpos];
112 ++wpos;
113 ++rpos;
114 }

◆ copy() [2/2]

void c4::yml::FilterProcessorSrcDst::copy ( size_t num)
inlinenoexcept

Definition at line 115 of file filter_processor.hpp.

116 {
117 RYML_ASSERT_BASIC_(num);
118 RYML_ASSERT_BASIC_(rpos+num <= src.len);
119 if(wpos + num <= dst.len)
120 memcpy(dst.str + wpos, src.str + rpos, num);
121 wpos += num;
122 rpos += num;
123 }

◆ translate_esc()

void c4::yml::FilterProcessorSrcDst::translate_esc ( char c)
inlinenoexcept

Definition at line 125 of file filter_processor.hpp.

126 {
127 if(wpos < dst.len)
128 dst.str[wpos] = c;
129 ++wpos;
130 rpos += 2;
131 }

◆ translate_esc_bulk()

void c4::yml::FilterProcessorSrcDst::translate_esc_bulk ( const char * s,
size_t nw,
size_t nr )
inlinenoexcept

Definition at line 132 of file filter_processor.hpp.

133 {
134 RYML_ASSERT_BASIC_(nw > 0);
135 RYML_ASSERT_BASIC_(nr > 0);
136 RYML_ASSERT_BASIC_(rpos+nr <= src.len);
137 if(wpos+nw <= dst.len)
138 memcpy(dst.str + wpos, s, nw);
139 wpos += nw;
140 rpos += 1 + nr;
141 }

Referenced by translate_esc_extending().

◆ translate_esc_extending()

void c4::yml::FilterProcessorSrcDst::translate_esc_extending ( const char * s,
size_t nw,
size_t nr )
inlinenoexcept

Definition at line 142 of file filter_processor.hpp.

143 {
144 translate_esc_bulk(s, nw, nr);
145 }
void translate_esc_bulk(const char *s, size_t nw, size_t nr) noexcept

Member Data Documentation

◆ src

csubstr c4::yml::FilterProcessorSrcDst::src

◆ dst

substr c4::yml::FilterProcessorSrcDst::dst

◆ rpos

size_t c4::yml::FilterProcessorSrcDst::rpos

◆ wpos

size_t c4::yml::FilterProcessorSrcDst::wpos

The documentation for this struct was generated from the following file:
  • /home/docs/checkouts/readthedocs.org/user_builds/rapidyaml/checkouts/latest/src/c4/yml/filter_processor.hpp