rapidyaml 0.14.0
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 54 of file filter_processor.hpp.

Constructor & Destructor Documentation

◆ FilterProcessorSrcDst()

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

Definition at line 61 of file filter_processor.hpp.

62 : src(src_)
63 , dst(dst_)
64 , rpos(0)
65 , wpos(0)
66 {
67 _RYML_ASSERT_BASIC(!dst.overlaps(src));
68 }

Member Function Documentation

◆ setwpos()

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

Definition at line 70 of file filter_processor.hpp.

70{ wpos = wpos_; }

◆ setpos()

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

Definition at line 71 of file filter_processor.hpp.

71{ rpos = rpos_; wpos = wpos_; }

◆ set_at_end()

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

Definition at line 72 of file filter_processor.hpp.

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

◆ has_more_chars() [1/2]

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

Definition at line 74 of file filter_processor.hpp.

74{ return rpos < src.len; }

◆ has_more_chars() [2/2]

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

Definition at line 75 of file filter_processor.hpp.

75{ _RYML_ASSERT_BASIC(maxpos <= src.len); return rpos < maxpos; }

◆ rem()

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

Definition at line 77 of file filter_processor.hpp.

77{ return src.sub(rpos); }

◆ sofar()

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

Definition at line 78 of file filter_processor.hpp.

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

◆ result()

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

Definition at line 79 of file filter_processor.hpp.

80 {
81 FilterResult ret;
82 ret.str.str = wpos <= dst.len ? dst.str : nullptr;
83 ret.str.len = wpos;
84 return ret;
85 }

◆ curr()

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

Definition at line 87 of file filter_processor.hpp.

87{ _RYML_ASSERT_BASIC(rpos < src.len); return src[rpos]; }

◆ next()

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

Definition at line 88 of file filter_processor.hpp.

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

◆ skipped_chars()

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

Definition at line 89 of file filter_processor.hpp.

89{ return wpos != rpos; }

◆ skip() [1/2]

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

Definition at line 91 of file filter_processor.hpp.

91{ ++rpos; }

◆ skip() [2/2]

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

Definition at line 92 of file filter_processor.hpp.

92{ rpos += num; }

◆ set_at()

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

Definition at line 94 of file filter_processor.hpp.

95 {
96 _RYML_ASSERT_BASIC(pos < wpos);
97 dst.str[pos] = c;
98 }

◆ set() [1/2]

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

Definition at line 99 of file filter_processor.hpp.

100 {
101 if(wpos < dst.len)
102 dst.str[wpos] = c;
103 ++wpos;
104 }

◆ set() [2/2]

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

Definition at line 105 of file filter_processor.hpp.

106 {
107 _RYML_ASSERT_BASIC(num > 0);
108 if(wpos + num <= dst.len)
109 memset(dst.str + wpos, c, num);
110 wpos += num;
111 }

◆ copy() [1/2]

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

Definition at line 113 of file filter_processor.hpp.

114 {
115 _RYML_ASSERT_BASIC(rpos < src.len);
116 if(wpos < dst.len)
117 dst.str[wpos] = src.str[rpos];
118 ++wpos;
119 ++rpos;
120 }

◆ copy() [2/2]

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

Definition at line 121 of file filter_processor.hpp.

122 {
123 _RYML_ASSERT_BASIC(num);
124 _RYML_ASSERT_BASIC(rpos+num <= src.len);
125 if(wpos + num <= dst.len)
126 memcpy(dst.str + wpos, src.str + rpos, num);
127 wpos += num;
128 rpos += num;
129 }

◆ translate_esc()

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

Definition at line 131 of file filter_processor.hpp.

132 {
133 if(wpos < dst.len)
134 dst.str[wpos] = c;
135 ++wpos;
136 rpos += 2;
137 }

◆ translate_esc_bulk()

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

Definition at line 138 of file filter_processor.hpp.

139 {
140 _RYML_ASSERT_BASIC(nw > 0);
141 _RYML_ASSERT_BASIC(nr > 0);
142 _RYML_ASSERT_BASIC(rpos+nr <= src.len);
143 if(wpos+nw <= dst.len)
144 memcpy(dst.str + wpos, s, nw);
145 wpos += nw;
146 rpos += 1 + nr;
147 }

◆ translate_esc_extending()

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

Definition at line 148 of file filter_processor.hpp.

149 {
150 translate_esc_bulk(s, nw, nr);
151 }
void translate_esc_bulk(const char *s, size_t nw, size_t nr) noexcept

Member Data Documentation

◆ src

csubstr c4::yml::FilterProcessorSrcDst::src

Definition at line 56 of file filter_processor.hpp.

◆ dst

substr c4::yml::FilterProcessorSrcDst::dst

Definition at line 57 of file filter_processor.hpp.

◆ rpos

size_t c4::yml::FilterProcessorSrcDst::rpos

read position

Definition at line 58 of file filter_processor.hpp.

◆ wpos

size_t c4::yml::FilterProcessorSrcDst::wpos

write position

Definition at line 59 of file filter_processor.hpp.


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