4 #include <dballe/fwd.h> 23 virtual std::string
pathname()
const = 0;
26 virtual Encoding
encoding()
const = 0;
31 virtual void close() = 0;
52 virtual bool foreach(std::function<
bool(
const BinaryMessage&)> dest) = 0;
55 virtual void write(
const std::string& msg) = 0;
67 static std::unique_ptr<File>
create(
const std::string&
pathname,
const char* mode);
81 static std::unique_ptr<File>
create(Encoding type,
const std::string&
pathname,
const char* mode);
98 static std::unique_ptr<File>
create(FILE* file,
bool close_on_exit,
const std::string& name=
"(fp)");
116 static std::unique_ptr<File>
create(Encoding type, FILE* file,
bool close_on_exit,
const std::string& name=
"(fp)");
160 operator bool()
const;
165 std::ostream& operator<<(std::ostream&,
const dballe::Encoding&);
static Encoding parse_encoding(const char *s)
Return the Encoding corresponding to the given name.
Binary message.
Definition: file.h:130
static const char * encoding_name(Encoding enc)
Return a string with the name of this encoding.
static std::unique_ptr< File > create(const std::string &pathname, const char *mode)
Open a file from the filesystem, autodetecting the encoding type.
std::string data
Binary message data.
Definition: file.h:137
virtual std::string pathname() const =0
Get the file pathname.
virtual void close()=0
Close the underlying file.
File object for doing I/O on binary message streams.
Definition: file.h:17
virtual Encoding encoding() const =0
Get the file encoding.
std::string pathname
Pathname of the file from where the BinaryMessage has been read.
Definition: file.h:144
virtual BinaryMessage read()=0
Read a message from the file.
Encoding encoding
Format of the binary data.
Definition: file.h:134
off_t offset
Start offset of this message inside the file.
Definition: file.h:147
virtual void write(const std::string &msg)=0
Append the binary message to the file.
int index
Index of the message from the beginning of the file.
Definition: file.h:150