rapidyaml  0.16.0
parseandemitYAML,anddoitfast
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 More...
 
size_t wpos
 write position More...
 

Detailed Description

Filters an input string into a different output string.

Definition at line 48 of file filter_processor.hpp.

Constructor & Destructor Documentation

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  }
bool overlaps(ro_substr const that) const noexcept
true if there is overlap of at least one element between that and *this
Definition: substr.hpp:493

Member Function Documentation

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

Definition at line 64 of file filter_processor.hpp.

64 { wpos = wpos_; }
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_; }
void c4::yml::FilterProcessorSrcDst::set_at_end ( )
inlinenoexcept

Definition at line 66 of file filter_processor.hpp.

66 { skip(src.len - rpos); }
size_t len
the length of the substring
Definition: substr.hpp:218
bool c4::yml::FilterProcessorSrcDst::has_more_chars ( ) const
inlinenoexcept

Definition at line 68 of file filter_processor.hpp.

68 { return rpos < src.len; }
size_t len
the length of the substring
Definition: substr.hpp:218
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; }
size_t len
the length of the substring
Definition: substr.hpp:218
csubstr c4::yml::FilterProcessorSrcDst::rem ( ) const
inlinenoexcept

Definition at line 71 of file filter_processor.hpp.

71 { return src.sub(rpos); }
basic_substring sub(size_t first) const noexcept
return [first,len[
Definition: substr.hpp:502
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); }
C * str
a restricted pointer to the first character of the substring
Definition: substr.hpp:216
basic_substring< const char > csubstr
an immutable string view
Definition: substr.hpp:2356
size_t len
the length of the substring
Definition: substr.hpp:218
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  }
C * str
a restricted pointer to the first character of the substring
Definition: substr.hpp:216
size_t len
the length of the substring
Definition: substr.hpp:218
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]; }
size_t len
the length of the substring
Definition: substr.hpp:218
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'; }
size_t len
the length of the substring
Definition: substr.hpp:218
bool c4::yml::FilterProcessorSrcDst::skipped_chars ( ) const
inlinenoexcept

Definition at line 83 of file filter_processor.hpp.

83 { return wpos != rpos; }
void c4::yml::FilterProcessorSrcDst::skip ( )
inlinenoexcept

Definition at line 85 of file filter_processor.hpp.

Referenced by set_at_end().

85 { ++rpos; }
void c4::yml::FilterProcessorSrcDst::skip ( size_t  num)
inlinenoexcept

Definition at line 86 of file filter_processor.hpp.

86 { rpos += num; }
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  }
C * str
a restricted pointer to the first character of the substring
Definition: substr.hpp:216
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  }
C * str
a restricted pointer to the first character of the substring
Definition: substr.hpp:216
size_t len
the length of the substring
Definition: substr.hpp:218
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  }
C * str
a restricted pointer to the first character of the substring
Definition: substr.hpp:216
size_t len
the length of the substring
Definition: substr.hpp:218
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  }
C * str
a restricted pointer to the first character of the substring
Definition: substr.hpp:216
size_t len
the length of the substring
Definition: substr.hpp:218
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  }
C * str
a restricted pointer to the first character of the substring
Definition: substr.hpp:216
size_t len
the length of the substring
Definition: substr.hpp:218
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  }
C * str
a restricted pointer to the first character of the substring
Definition: substr.hpp:216
size_t len
the length of the substring
Definition: substr.hpp:218
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.

Referenced by translate_esc_extending().

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  }
C * str
a restricted pointer to the first character of the substring
Definition: substr.hpp:216
size_t len
the length of the substring
Definition: substr.hpp:218
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

csubstr c4::yml::FilterProcessorSrcDst::src

Definition at line 50 of file filter_processor.hpp.

substr c4::yml::FilterProcessorSrcDst::dst

Definition at line 51 of file filter_processor.hpp.

size_t c4::yml::FilterProcessorSrcDst::rpos

read position

Definition at line 52 of file filter_processor.hpp.

Referenced by copy(), curr(), skip(), and skipped_chars().

size_t c4::yml::FilterProcessorSrcDst::wpos

write position

Definition at line 53 of file filter_processor.hpp.

Referenced by copy(), result(), set(), and translate_esc().


The documentation for this struct was generated from the following file: