8namespace pflib::packing {
34 file_.
open(file_name, std::ios::out | std::ios::binary);
59 template <
typename WordType,
60 std::enable_if_t<std::is_integral<WordType>::value,
bool> =
true>
62 file_.
write(
reinterpret_cast<const char*
>(w),
sizeof(WordType) * num);
75 template <
typename WordType,
76 std::enable_if_t<std::is_integral<WordType>::value,
bool> =
true>
90 template <
typename WordType,
91 std::enable_if_t<std::is_integral<WordType>::value,
bool> =
true>
110 template <
typename ObjectType,
111 std::enable_if_t<std::is_class<ObjectType>::value,
bool> =
true>
113 return o.
write(*
this);
126 template <
typename ObjectType,
127 std::enable_if_t<std::is_class<ObjectType>::value,
bool> =
true>
129 for (
auto const& o : vec)
130 if (!o.write(*
this))
return *
this;
Writing a raw data file.
Definition Writer.h:17
Writer & operator<<(const WordType &w)
Write a single integral-type word to the output file stream.
Definition Writer.h:77
Writer & operator<<(const std::vector< ObjectType > &vec)
Write out a vector fo class objects.
Definition Writer.h:128
Writer & write(const WordType *w, std::size_t num)
Write a certain number of words from the input array to the output file stream.
Definition Writer.h:61
Writer & operator<<(const ObjectType &o)
Write out a class object.
Definition Writer.h:112
Writer & operator<<(const std::vector< WordType > &vec)
Write out a vector of integral-type objects.
Definition Writer.h:92
bool operator!() const
Check if writer is in a fail state.
Definition Writer.h:141
Writer(const std::string &file_name)
Open the input file name upon construction of this writer.
Definition Writer.h:42
Writer()
default constructor
Definition Writer.h:24
void open(const std::string &file_name)
Open a file with this writer.
Definition Writer.h:33
~Writer()=default
destructor, close the input file stream
std::ofstream file_
file stream we are writing to
Definition Writer.h:154