LDMX Software
|
Writing a raw data file. More...
#include <Writer.h>
Public Member Functions | |
Writer () | |
default constructor | |
void | open (const std::string &file_name) |
Open a file with this writer. | |
Writer (const std::string &file_name) | |
Open the input file name upon construction of this writer. | |
~Writer ()=default | |
destructor, close the input file stream | |
template<typename WordType , std::enable_if_t< std::is_integral< WordType >::value, bool > = true> | |
Writer & | write (const WordType *w, std::size_t num) |
Write a certain number of words from the input array to the output file stream. | |
template<typename WordType , std::enable_if_t< std::is_integral< WordType >::value, bool > = true> | |
Writer & | operator<< (const WordType &w) |
Write a single integral-type word to the output file stream. | |
template<typename WordType , std::enable_if_t< std::is_integral< WordType >::value, bool > = true> | |
Writer & | operator<< (const std::vector< WordType > &vec) |
Write out a vector of integral-type objects. | |
template<typename ObjectType , std::enable_if_t< std::is_class< ObjectType >::value, bool > = true> | |
Writer & | operator<< (const ObjectType &o) |
Write out a class object. | |
template<typename ObjectType , std::enable_if_t< std::is_class< ObjectType >::value, bool > = true> | |
Writer & | operator<< (const std::vector< ObjectType > &vec) |
Write out a vector fo class objects. | |
bool | operator! () const |
Check if writer is in a fail state. | |
operator bool () const | |
Check if writer is in a good/bad state. | |
Private Attributes | |
std::ofstream | file_ |
file stream we are writing to | |
Writing a raw data file.
We wrap a basic std::ifstream in order to make the writing of specific-width words easier for ourselves.
|
inline |
default constructor
make sure we don't skip "whitespace"
Definition at line 26 of file Writer.h.
References file_.
|
inline |
Open the input file name upon construction of this writer.
[in] | file_name | name of file to open |
Definition at line 44 of file Writer.h.
References open().
|
inline |
Open a file with this writer.
We open the file stream in output, binary mode.
[in] | file_name | name of file to open |
Definition at line 35 of file Writer.h.
References file_.
Referenced by packing::SingleSubsystemPacker::configure(), packing::rawdatafile::File::File(), and Writer().
|
inline |
|
inline |
|
inline |
Write out a class object.
We assume that the input class object has a specific method defined.
Writer& write(Writer&) const;
With this method defined, then the class can be streamed out through this object.
in] ObjectType class-type to write out
[in] | o | object to write out |
Definition at line 114 of file Writer.h.
References write().
|
inline |
Write out a vector fo class objects.
We make the same assumptions as when streaming out a single class object. We leave early if any write action changes the file to a fail state.
in] ObjectType class-type inside vector to write out
[in] | vec | vector of objects to write out |
Definition at line 130 of file Writer.h.
|
inline |
|
inline |
|
inline |
Write a certain number of words from the input array to the output file stream.
This method is only enabled for integral types so we can safely reinterpret the underlying data as an array of characters.
in] WordType integral-type to write out
[in] | w | pointer to array of words to write |
[in] | num | number of words in array |
Definition at line 63 of file Writer.h.
References file_, and write().
Referenced by operator<<(), operator<<(), operator<<(), and write().
|
private |
file stream we are writing to
Definition at line 156 of file Writer.h.
Referenced by open(), operator bool(), operator!(), write(), and Writer().