2 #ifndef vsl_binary_io_h_ 3 #define vsl_binary_io_h_ 22 # include <vcl_msvc_warnings.h> 24 #include <vxl_config.h> 25 #include <vsl/vsl_export.h> 48 std::ostream&
os()
const;
111 typedef std::map<void *, std::pair<unsigned long, int>, std::less<void *> >
131 std::ios::openmode mode = std::ios::out | std::ios::trunc):
132 vsl_b_ostream(new std::ofstream(filename.c_str(), mode | std::ios::binary)) {}
137 std::ios::openmode mode = std::ios::out | std::ios::trunc) :
138 vsl_b_ostream(new std::ofstream(filename, mode | std::ios::binary)) {}
176 std::istream &
is()
const;
199 void *pointer,
int other_data = 0);
223 typedef std::map<unsigned long, std::pair<void *, int>, std::less<unsigned long> >
243 vsl_b_ifstream(
const std::string &filename, std::ios::openmode mode = std::ios::in):
245 mode | std::ios::binary)) {}
250 vsl_b_istream(new std::ifstream(filename, mode | std::ios::binary)) {}
324 # define VCL_64BIT_ATTR __w64 326 # define VCL_64BIT_ATTR 337 #undef VCL_64BIT_ATTR 379 #if VXL_HAS_INT_64 && !VXL_INT_64_IS_LONG 401 #endif // VXL_HAS_INT_64 422 #endif // vsl_binary_io_h_
A binary output adaptor for any std::ostream.
An adapter for a std::ifstream to make it suitable for binary IO.
void vsl_b_read(vsl_b_istream &is, bool &b)
Read bool from vsl_b_istream.
virtual int set_serialisation_other_data(void *pointer, int other_data)
Modify the user-defined data associated with the object.
virtual int set_serialisation_other_data(unsigned long serial_number, int other_data)
Modify the user-defined data associated with the unique serial number.
vsl_b_istream(std::istream *is)
Create this adaptor using an existing stream.
~vsl_b_ofstream() override
Virtual destructor.
bool operator!() const
Returns true if the underlying stream has its fail bit set.
unsigned short version_no() const
Return the version number of the IO format of the file being read.
std::ostream * os_
The member stream.
virtual void clear_serialisation_records()
Clear the stream's record of any serialisation operations.
virtual int get_serialisation_other_data(void *pointer) const
Set the user-defined data associated with the object.
std::istream & is() const
A reference to the adaptor's stream.
void vsl_print_summary(std::ostream &os, bool b)
Print to a stream.
serialisation_records_type serialisation_records_
The serialisation records,.
bool vsl_b_istream_test(std::istream &is)
Test to see if a stream really is a binary vsl file.
bool operator!() const
Returns true if the underlying stream has its fail bit set.
vsl_b_ofstream(const char *filename, std::ios::openmode mode=std::ios::out|std::ios::trunc)
Create this adaptor from a file.
vsl_b_ifstream(const std::string &filename, std::ios::openmode mode=std::ios::in)
Create this adaptor from a file.
static constexpr unsigned short version_no_
The version number of the IO scheme.
virtual int get_serialisation_other_data(unsigned long serial_number) const
Returns the user defined data associated with the unique serial number.
virtual ~vsl_b_ostream()=default
Virtual destructor.
vsl_b_ofstream(const std::string &filename, std::ios::openmode mode=std::ios::out|std::ios::trunc)
Create this adaptor from a file.
virtual unsigned long get_serial_number(void *pointer) const
Returns a unique identifier for the object.
virtual void * get_serialisation_pointer(unsigned long serial_number) const
Returns the pointer to the object identified by the unique serial number.
void close()
Close the stream.
virtual unsigned long add_serialisation_record(void *pointer, int other_data=0)
Adds an object pointer to the serialisation records.
static constexpr std::streamoff header_length
The length of the b_stream header.
~vsl_b_ifstream() override
Virtual destructor.so that it can be overloaded.
std::map< unsigned long, std::pair< void *, int >, std::less< unsigned long > > serialisation_records_type
The type of the serialisation records.
unsigned short version_no_
virtual void add_serialisation_record(unsigned long serial_number, void *pointer, int other_data=0)
Adds record of object's unique serial number, and location in memory.
An adaptor for any std::istream to make it suitable for binary input.
An adapter for a std::ofstream to make it suitable for binary IO.
std::istream * is_
The member stream.
virtual void clear_serialisation_records()
Clear the stream's record of any serialisation operations.
serialisation_records_type serialisation_records_
The serialisation records.
std::ostream & os() const
A reference to the adaptor's stream.
std::map< void *, std::pair< unsigned long, int >, std::less< void * > > serialisation_records_type
The type of the serialisation records.
virtual ~vsl_b_istream()=default
Virtual destructor.so that it can be overloaded.
void close()
Close the stream.
vsl_b_ifstream(const char *filename, std::ios::openmode mode=std::ios::in)
Create this adaptor from a file.
vsl_b_ostream(std::ostream *os)
Create this adaptor using an existing stream.
void vsl_b_write(vsl_b_ostream &os, bool b)
Write bool to vsl_b_ostream.