a CRTP base providing read-only methods for ConstNodeRef and NodeRef
More...
a CRTP base providing read-only methods for ConstNodeRef and NodeRef
◆ _get_text_region()
| csubstr c4::yml::detail::_get_text_region |
( |
csubstr | text, |
|
|
size_t | pos, |
|
|
size_t | num_lines_before, |
|
|
size_t | num_lines_after ) |
Definition at line 283 of file common.cpp.
284{
288 size_t before_count = 0;
289 while((before !=
npos) && (++before_count <= num_lines_before))
290 {
291 if(before == 0)
292 break;
294 }
295 if(before < text.
len || before ==
npos)
296 ++before;
297 size_t after = text.
first_of(
'\n', pos);
298 size_t after_count = 0;
299 while((after !=
npos) && (++after_count <= num_lines_after))
300 {
301 ++after;
302 if(after >= text.
len)
303 break;
305 }
306 return before <= after ? text.
range(before, after) : text.
first(0);
307}
@ npos
a null string position
basic_substring range(size_t first, size_t last=npos) const noexcept
return [first,last[.
size_t last_of(const C c, size_t start=npos) const
size_t len
the length of the substring
basic_substring last(size_t num) const noexcept
return the last num elements: [len-num,len[
size_t first_of(const C c, size_t start=0) const
basic_substring first(size_t num) const noexcept
return the first num elements: [0,num[