rapidyaml 0.15.2
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches

A writer that outputs to a C file handle, defaulting to stdout. More...

#include <writer_file.hpp>

Public Member Functions

 WriterFile (FILE *f=nullptr) noexcept
template<size_t N>
void append (const char(&a)[N]) noexcept
void append (csubstr s) noexcept
void append (const char c) noexcept
void append (const char c, size_t num_times) noexcept

Public Attributes

FILE * m_file

Detailed Description

A writer that outputs to a C file handle, defaulting to stdout.

This writer is much faster than WriterOStream and should be preferred to it.

Definition at line 21 of file writer_file.hpp.

Constructor & Destructor Documentation

◆ WriterFile()

c4::yml::WriterFile::WriterFile ( FILE * f = nullptr)
inlinenoexcept

Definition at line 25 of file writer_file.hpp.

25: m_file(f ? f : stdout) {}

Member Function Documentation

◆ append() [1/4]

template<size_t N>
void c4::yml::WriterFile::append ( const char(&) a[N])
inlinenoexcept

Definition at line 28 of file writer_file.hpp.

29 {
30 static_assert(N > 1, "empty string");
31 (void)fwrite(a, sizeof(char), N - 1, m_file);
32 }

◆ append() [2/4]

void c4::yml::WriterFile::append ( csubstr s)
inlinenoexcept

Definition at line 34 of file writer_file.hpp.

35 {
36 if(s.len)
37 {
38 C4_SUPPRESS_WARNING_GCC_CLANG_WITH_PUSH("-Wsign-conversion")
39 (void)fwrite(s.str, sizeof(csubstr::char_type), s.len, m_file);
40 C4_SUPPRESS_WARNING_GCC_CLANG_POP
41 }
42 }

◆ append() [3/4]

void c4::yml::WriterFile::append ( const char c)
inlinenoexcept

Definition at line 44 of file writer_file.hpp.

45 {
46 (void)fputc(c, m_file);
47 }

◆ append() [4/4]

void c4::yml::WriterFile::append ( const char c,
size_t num_times )
inlinenoexcept

Definition at line 49 of file writer_file.hpp.

50 {
51 for(size_t i = 0; i < num_times; ++i)
52 (void)fputc(c, m_file);
53 }

Member Data Documentation

◆ m_file

FILE* c4::yml::WriterFile::m_file

Definition at line 23 of file writer_file.hpp.


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