libdballe  7.7
Public Member Functions | Protected Member Functions
dballe::core::AofFile Class Reference
Inheritance diagram for dballe::core::AofFile:
dballe::core::File dballe::File

Public Member Functions

 AofFile (const std::string &name, FILE *fd, bool close_on_exit=true)
 
virtual Encoding encoding () const override
 Get the file encoding.
 
BinaryMessage read () override
 Read a message from the file. More...
 
void write (const std::string &msg) override
 Append the binary message to the file.
 
void read_header ()
 Read the file header, perform some consistency checks then discard the data.
 
void write_dummy_header ()
 Write a dummy file header.
 
void fix_header ()
 Rewrite the file header, scanning the file to compute a correct one.
 
- Public Member Functions inherited from dballe::core::File
 File (const std::string &name, FILE *fd, bool close_on_exit=true)
 
std::string pathname () const override
 Get the file pathname.
 
bool foreach (std::function< bool(const BinaryMessage &)> dest) override
 Read all the messages from the file, calling the function on each of them. More...
 

Protected Member Functions

bool read_record (std::string &res)
 Read a Fortran Unformatted Sequential Binary record from a file. More...
 
void write_record (const std::string &res)
 Write a Fortran Unformatted Sequential Binary record to a file. More...
 
void write_record (const uint32_t *words, size_t wordcount)
 Write a Fortran Unformatted Sequential Binary record to a file. More...
 
void write_word (uint32_t word)
 Write a word to the file, byteswapping it for endianness if needed.
 

Additional Inherited Members

- Public Types inherited from dballe::File
enum  Encoding { BUFR = 0, CREX = 1, AOF = 2 }
 Supported encodings.
 
- Static Public Member Functions inherited from dballe::core::File
static std::string resolve_test_data_file (const std::string &name)
 Resolve the location of a test data file. More...
 
static std::unique_ptr< dballe::Fileopen_test_data_file (Encoding type, const std::string &name)
 Open a test data file. More...
 
- Static Public Member Functions inherited from dballe::File
static std::unique_ptr< Filecreate (const std::string &pathname, const char *mode)
 Open a file from the filesystem, autodetecting the encoding type. More...
 
static std::unique_ptr< Filecreate (Encoding type, const std::string &pathname, const char *mode)
 Open a file from the filesystem. More...
 
static std::unique_ptr< Filecreate (FILE *file, bool close_on_exit, const std::string &name="(fp)")
 Create a File from an existing FILE* stream, autodetecting the encoding type. More...
 
static std::unique_ptr< Filecreate (Encoding type, FILE *file, bool close_on_exit, const std::string &name="(fp)")
 Create a File from an existing FILE* stream. More...
 
static const char * encoding_name (Encoding enc)
 Return a string with the name of this encoding.
 
static Encoding parse_encoding (const char *s)
 Return the Encoding corresponding to the given name.
 
static Encoding parse_encoding (const std::string &s)
 Return the Encoding corresponding to the given name.
 
- Protected Attributes inherited from dballe::core::File
std::string m_name
 Name of the file.
 
FILE * fd
 FILE structure used to read or write to the file.
 
bool close_on_exit
 True if fd should be closed on destruction.
 
int idx
 Index of the last message read from the file or written to the file.
 

Member Function Documentation

BinaryMessage dballe::core::AofFile::read ( )
overridevirtual

Read a message from the file.

Returns
the BinaryMessage with the binary data that have been read, or nullptr when the end of file has been reached.

Implements dballe::File.

bool dballe::core::AofFile::read_record ( std::string &  res)
protected

Read a Fortran Unformatted Sequential Binary record from a file.

Parameters
resThe data read. The resulting data is an array of 32bit words that will be byteswapped to native endianness if needed.
Returns
true if a record was found, false on EOF
void dballe::core::AofFile::write_record ( const std::string &  res)
protected

Write a Fortran Unformatted Sequential Binary record to a file.

Parameters
resThe data to be written, considered an array of 32bit words that will be byteswapped for endianness if needed
void dballe::core::AofFile::write_record ( const uint32_t *  words,
size_t  wordcount 
)
protected

Write a Fortran Unformatted Sequential Binary record to a file.

Parameters
wordsThe data to be written, as an array of 32bit words that will be byteswapped for endianness if needed

The documentation for this class was generated from the following file: