1 #ifndef C4_YML_WRITER_BUF_HPP_
2 #define C4_YML_WRITER_BUF_HPP_
4 #ifndef C4_YML_ERROR_HPP_
13 C4_SUPPRESS_WARNING_MSVC_WITH_PUSH(4251)
33 if(m_pos <= m_buf.
len)
35 return m_buf.
first(m_pos);
37 else if(!error_on_excess)
46 RYML_ERR_BASIC_(
"not enough space in the given buffer");
53 C4_ALWAYS_INLINE
void append(
const char (&a)[N]) noexcept
55 static_assert(N > 1,
"empty string");
56 RYML_ASSERT_BASIC_( ! m_buf.
overlaps(a));
57 if(m_pos + N-1 <= m_buf.
len)
58 memcpy(m_buf.
str + m_pos, a, N-1);
64 RYML_ASSERT_BASIC_( ! s.overlaps(m_buf));
65 if(s.len && m_pos + s.len <= m_buf.
len)
66 memcpy(m_buf.
str + m_pos, s.str, s.len);
70 C4_ALWAYS_INLINE
void append(
const char c) noexcept
72 if(m_pos + 1 <= m_buf.
len)
77 C4_ALWAYS_INLINE
void append(
const char c,
size_t num_times) noexcept
79 if(m_pos + num_times <= m_buf.
len)
80 memset(m_buf.
str + m_pos, c, num_times);
85 C4_SUPPRESS_WARNING_MSVC_POP
void append(const char c) noexcept
bool overlaps(ro_substr const that) const noexcept
true if there is overlap of at least one element between that and *this
C * str
a restricted pointer to the first character of the substring
basic_substring first(size_t num) const noexcept
return the first num elements: [0,num[
A writer to a memory buffer, in the form of a substr .
substr get_result(bool error_on_excess) const
Return the buffer written so far, or optionally throw an error if the buffer was too small...
void append(const char(&a)[N]) noexcept
void append(const char c, size_t num_times) noexcept
size_t len
the length of the substring
Error utilities used by ryml.
WriterBuf(substr sp) noexcept
void append(csubstr s) noexcept