40 #ifndef GEOGRAM_BASIC_B_STREAM
41 #define GEOGRAM_BASIC_B_STREAM
79 static const int GEO_LITTLE_ENDIAN = 0;
82 static const int GEO_BIG_ENDIAN = 1;
100 return stream_endian_;
109 return machine_endian_;
117 return has_record_markers_;
128 has_record_markers_ = b;
164 bool has_record_markers_;
188 const std::string& file_name,
int stream_endian = GEO_BIG_ENDIAN
202 std::istream& input,
int stream_endian = GEO_BIG_ENDIAN
254 input_->
read((
char*) ptr, (std::streamsize) n);
269 void* ptr,
size_t size,
size_t n
271 return read_opaque_data(ptr, size * n);
342 return input_->tellg();
349 void seek(std::streamoff pos) {
361 void seek(std::streamoff off, std::ios_base::seekdir dir) {
362 input_->seekg(off, dir);
373 return read_opaque_data(data, n);
401 std::istream* input_;
434 const std::string& file_name,
int stream_endian = GEO_BIG_ENDIAN
448 std::ostream& output,
int stream_endian = GEO_BIG_ENDIAN
488 const void* ptr,
size_t size
490 output_->
write((
const char*) ptr, (std::streamsize) size);
505 const void* ptr,
size_t size,
size_t n
507 return write_opaque_data(ptr, size * n);
523 (
const char*) data, n,
565 (
const char*) data, n,
580 return write_opaque_data(data, n);
614 std::ostream* output_;
BinaryOutputStream & write_opaque_data(const void *ptr, size_t size, size_t n)
Writes opaque data.
BinaryOutputStream & write_opaque_data(const void *ptr, size_t size)
Writes opaque data.
BinaryOutputStream(const std::string &file_name, int stream_endian=GEO_BIG_ENDIAN)
Creates a new binary output stream.
bool OK() const
Gets the status of the stream.
BinaryOutputStream & write(const char *data, size_t n, ItemSize< 2 >)
Writes an array of elements of size 2.
BinaryOutputStream & write(const char *data, size_t n, ItemSize< 1 >)
Writes an array of elements of size 1.
BinaryOutputStream(std::ostream &output, int stream_endian=GEO_BIG_ENDIAN)
Creates a new binary output stream.
BinaryOutputStream & write(const char *data, size_t n, ItemSize< 4 >)
Writes an array of elements of size 4.
~BinaryOutputStream()
Deletes the output stream.
BinaryOutputStream & write_array(const T *data, size_t n)
Writes an array of elements.
BinaryOutputStream & write_record(const T *data, size_t n)
Writes an array of elements in a record.
void begin_record()
Starts writing a data record.
BinaryOutputStream & write(const char *data, size_t n, ItemSize< 8 >)
Writes an array of elements of size 8.
void end_record()
Stops writing a data record.
Binary stream base class.
void set_has_record_markers(bool b)
Enables/disables support for record markers.
bool has_record_markers() const
Checks support for record markers.
BinaryStream(int stream_endian=GEO_BIG_ENDIAN)
Base constructor.
void detect_machine_endian()
Detects the current architecture's endianness.
int machine_endian() const
Gets the current architecture's endianness.
void set_stream_endian(int stream_endian)
Sets the stream endianness.
int stream_endian() const
Gets the stream endianness.
Common include file, providing basic definitions. Should be included before anything else by all head...
Global Vorpaline namespace.
std::ostream & operator<<(std::ostream &out, const Quaternion &q)
Writes a Quaternion to a stream.
std::istream & operator>>(std::istream &in, Quaternion &q)
Reads a Quaternion from a stream.
Types and functions for numbers manipulation.
Extends std::numeric_limits with additional information.