libdballe 9.6
|
File object for doing I/O on binary message streams. More...
#include <file.h>
Public Member Functions | |
virtual std::string | pathname () const =0 |
Get the file pathname. | |
virtual Encoding | encoding () const =0 |
Get the file encoding. | |
virtual void | close ()=0 |
Close the underlying file. | |
virtual BinaryMessage | read ()=0 |
Read a message from the file. | |
virtual bool | foreach (std::function< bool(const BinaryMessage &)> dest)=0 |
Read all the messages from the file, calling the function on each of them. | |
virtual void | write (const std::string &msg)=0 |
Append the binary message to the file. | |
Static Public Member Functions | |
static std::unique_ptr< File > | create (const std::string &pathname, const char *mode) |
Open a file from the filesystem, autodetecting the encoding type. | |
static std::unique_ptr< File > | create (Encoding type, const std::string &pathname, const char *mode) |
Open a file from the filesystem. | |
static std::unique_ptr< File > | create (FILE *file, bool close_on_exit, const std::string &name="(fp)") |
Create a File from an existing FILE* stream, autodetecting the encoding type. | |
static std::unique_ptr< File > | create (Encoding type, FILE *file, bool close_on_exit, const std::string &name="(fp)") |
Create a File from an existing FILE* stream. | |
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. | |
File object for doing I/O on binary message streams.
It provides a unified interface to read and write messages to files.
|
pure virtual |
Close the underlying file.
Implemented in dballe::core::File.
|
static |
Open a file from the filesystem, autodetecting the encoding type.
pathname | The pathname of the file to access. |
mode | The opening mode of the file, as used by fopen. |
|
static |
Open a file from the filesystem.
type | The type of data contained in the file. |
pathname | The pathname of the file to access. |
mode | The opening mode of the file, as used by fopen. |
|
static |
Create a File from an existing FILE* stream.
type | The type of data contained in the file. |
file | The FILE* stream for the file to access. |
close_on_exit | If true, fclose() will be called on the stream when the File object is destroyed. |
name | Pathname or description of the stream, used when generating error messages |
|
static |
Create a File from an existing FILE* stream, autodetecting the encoding type.
file | The FILE* stream for the file to access. |
close_on_exit | If true, fclose() will be called on the stream when the File object is destroyed. |
name | Pathname or description of the stream, used when generating error messages |
|
pure virtual |
Get the file encoding.
Implemented in dballe::core::ArrayFile, dballe::core::BufrFile, dballe::core::CrexFile, and dballe::core::JsonFile.
|
pure virtual |
Read all the messages from the file, calling the function on each of them.
If dest returns false, reading will stop.
Implemented in dballe::core::File.
|
pure virtual |
Get the file pathname.
Implemented in dballe::core::File.
|
pure virtual |
Read a message from the file.
Implemented in dballe::core::ArrayFile, dballe::core::BufrFile, dballe::core::CrexFile, and dballe::core::JsonFile.
|
pure virtual |
Append the binary message to the file.
Implemented in dballe::core::ArrayFile, dballe::core::BufrFile, dballe::core::CrexFile, and dballe::core::JsonFile.