rapidyaml  0.16.0
parseandemitYAML,anddoitfast
file_put_contents()

Save a buffer to disk. More...

Functions

void c4::yml::file_put_contents (void const *buf, size_t sz, FILE *file, const char *filename=nullptr)
 save a contiguous buffer into a file More...
 
template<class ContiguousContainer >
void c4::yml::file_put_contents (ContiguousContainer const &v, FILE *file, const char *filename=nullptr)
 save a contiguous buffer into a file More...
 
void c4::yml::file_put_contents (void const *buf, size_t sz, const char *filename, const char *access="wb")
 save a contiguous buffer into a file More...
 
template<class ContiguousContainer >
void c4::yml::file_put_contents (ContiguousContainer const &v, const char *filename, const char *access="wb")
 save a contiguous buffer into a file More...
 

Detailed Description

Save a buffer to disk.

Function Documentation

void c4::yml::file_put_contents ( void const *  buf,
size_t  sz,
FILE *  file,
const char *  filename = nullptr 
)
inline

save a contiguous buffer into a file

Definition at line 57 of file file.hpp.

Referenced by c4::yml::file_put_contents(), and sample_parse_file().

58 {
59  size_t written = std::fwrite(buf, 1, sz, file); // NOLINT
60  if C4_UNLIKELY(written != sz)
61  RYML_ERR_BASIC_("{}: failed file write: expected={}B actual={}B", filename ? filename : "file", sz, written); // LCOV_EXCL_LINE
62 }
void write(NodeRef *n, T const &v)
Definition: node.hpp:2114
template<class ContiguousContainer >
void c4::yml::file_put_contents ( ContiguousContainer const &  v,
FILE *  file,
const char *  filename = nullptr 
)

save a contiguous buffer into a file

Definition at line 66 of file file.hpp.

67 {
68  size_t vsz = static_cast<size_t>(v.size()) * sizeof(typename ContiguousContainer::value_type);
69  void const* vbuf = v.empty() ? nullptr : &v[0];
70  file_put_contents(vbuf, vsz, file, filename);
71 }
void file_put_contents(ContiguousContainer const &v, const char *filename, const char *access="wb")
save a contiguous buffer into a file
Definition: file.hpp:82
void c4::yml::file_put_contents ( void const *  buf,
size_t  sz,
const char *  filename,
const char *  access = "wb" 
)
inline

save a contiguous buffer into a file

Definition at line 74 of file file.hpp.

75 {
76  detail::ScopedFILE f(filename, access);
77  file_put_contents(buf, sz, f.file, filename);
78 }
void file_put_contents(ContiguousContainer const &v, const char *filename, const char *access="wb")
save a contiguous buffer into a file
Definition: file.hpp:82
template<class ContiguousContainer >
void c4::yml::file_put_contents ( ContiguousContainer const &  v,
const char *  filename,
const char *  access = "wb" 
)

save a contiguous buffer into a file

Definition at line 82 of file file.hpp.

83 {
84  size_t vsz = static_cast<size_t>(v.size()) * sizeof(typename ContiguousContainer::value_type);
85  void const* vbuf = v.empty() ? nullptr : &v[0];
86  file_put_contents(vbuf, vsz, filename, access);
87 }
void file_put_contents(ContiguousContainer const &v, const char *filename, const char *access="wb")
save a contiguous buffer into a file
Definition: file.hpp:82