foobar2000 SDK  2015-01-14
Public Member Functions | Protected Member Functions
foobar2000_io::stream_writerabstract

#include <filesystem.h>

+ Inheritance diagram for foobar2000_io::stream_writer:

Public Member Functions

virtual void write (const void *p_buffer, t_size p_bytes, abort_callback &p_abort)=0
 
template<typename T >
void write_bendian_t (const T &p_object, abort_callback &p_abort)
 
template<typename T >
void write_lendian_t (const T &p_object, abort_callback &p_abort)
 
void write_object (const void *p_buffer, t_size p_bytes, abort_callback &p_abort)
 
template<typename T >
void write_object_t (const T &p_object, abort_callback &p_abort)
 
void write_string (const char *p_string, abort_callback &p_abort)
 
void write_string (const char *p_string, t_size p_len, abort_callback &p_abort)
 
template<typename T >
void write_string (const T &val, abort_callback &p_abort)
 
void write_string_nullterm (const char *p_string, abort_callback &p_abort)
 
void write_string_raw (const char *p_string, abort_callback &p_abort)
 

Protected Member Functions

 stream_writer ()
 
 ~stream_writer ()
 

Detailed Description

Generic interface to write data to a nonseekable stream. Also see: stream_reader, file.
Error handling: all methods may throw exception_io or one of derivatives on failure; exception_aborted when abort_callback is signaled.

Definition at line 161 of file filesystem.h.

Constructor & Destructor Documentation

foobar2000_io::stream_writer::stream_writer ( )
inlineprotected

Definition at line 197 of file filesystem.h.

197 {}
foobar2000_io::stream_writer::~stream_writer ( )
inlineprotected

Definition at line 198 of file filesystem.h.

198 {}

Member Function Documentation

virtual void foobar2000_io::stream_writer::write ( const void *  p_buffer,
t_size  p_bytes,
abort_callback p_abort 
)
pure virtual

Writes specified number of bytes from specified buffer to the stream.

Parameters
p_bufferBuffer with data to write. Must contain at least p_bytes bytes.
p_bytesNumber of bytes to write.
p_abortabort_callback object signaling user aborting the operation.
template<typename T >
void foobar2000_io::stream_writer::write_bendian_t ( const T p_object,
abort_callback p_abort 
)
inline

Helper template. Writes single raw object to the stream; corrects byte order assuming stream uses big endian order.

Parameters
p_objectObject to write.
p_abortabort_callback object signaling user aborting the operation.

Definition at line 183 of file filesystem.h.

183 {T temp = p_object; byte_order::order_native_to_be_t(temp); write_object_t(temp,p_abort);}
void write_object_t(const T &p_object, abort_callback &p_abort)
Helper template. Writes single raw object to the stream.
Definition: filesystem.h:175
void order_native_to_be_t(T &param)
template<typename T >
void foobar2000_io::stream_writer::write_lendian_t ( const T p_object,
abort_callback p_abort 
)
inline

Helper template. Writes single raw object to the stream; corrects byte order assuming stream uses little endian order.

Parameters
p_objectObject to write.
p_abortabort_callback object signaling user aborting the operation.

Definition at line 179 of file filesystem.h.

179 {T temp = p_object; byte_order::order_native_to_le_t(temp); write_object_t(temp,p_abort);}
void order_native_to_le_t(T &param)
void write_object_t(const T &p_object, abort_callback &p_abort)
Helper template. Writes single raw object to the stream.
Definition: filesystem.h:175
void foobar2000_io::stream_writer::write_object ( const void *  p_buffer,
t_size  p_bytes,
abort_callback p_abort 
)
inline

Helper. Same as write(), provided for consistency.

Definition at line 170 of file filesystem.h.

170 {write(p_buffer,p_bytes,p_abort);}
virtual void write(const void *p_buffer, t_size p_bytes, abort_callback &p_abort)=0
Writes specified number of bytes from specified buffer to the stream.
template<typename T >
void foobar2000_io::stream_writer::write_object_t ( const T p_object,
abort_callback p_abort 
)
inline

Helper template. Writes single raw object to the stream.

Parameters
p_objectObject to write.
p_abortabort_callback object signaling user aborting the operation.

Definition at line 175 of file filesystem.h.

175 {pfc::assert_raw_type<T>(); write_object(&p_object,sizeof(p_object),p_abort);}
void write_object(const void *p_buffer, t_size p_bytes, abort_callback &p_abort)
Helper. Same as write(), provided for consistency.
Definition: filesystem.h:170
void stream_writer::write_string ( const char *  p_string,
abort_callback p_abort 
)

Helper function; writes string (with 32-bit header indicating length in bytes followed by UTF-8 encoded data without null terminator).

Definition at line 733 of file filesystem.cpp.

733  {
734  write_string(p_string,~0,p_abort);
735 }
void write_string(const char *p_string, abort_callback &p_abort)
Helper function; writes string (with 32-bit header indicating length in bytes followed by UTF-8 encod...
Definition: filesystem.cpp:733
void stream_writer::write_string ( const char *  p_string,
t_size  p_len,
abort_callback p_abort 
)

Definition at line 727 of file filesystem.cpp.

727  {
728  t_uint32 len = pfc::downcast_guarded<t_uint32>(pfc::strlen_max(p_string,p_len));
729  write_lendian_t(len,p_abort);
730  write_object(p_string,len,p_abort);
731 }
t_size strlen_max(const char *ptr, t_size max)
Definition: string_base.h:91
void write_lendian_t(const T &p_object, abort_callback &p_abort)
Helper template. Writes single raw object to the stream; corrects byte order assuming stream uses lit...
Definition: filesystem.h:179
void write_object(const void *p_buffer, t_size p_bytes, abort_callback &p_abort)
Helper. Same as write(), provided for consistency.
Definition: filesystem.h:170
uint32_t t_uint32
Definition: int_types.h:5
template<typename T >
void foobar2000_io::stream_writer::write_string ( const T val,
abort_callback p_abort 
)
inline

Definition at line 190 of file filesystem.h.

190 {write_string(pfc::stringToPtr(val),p_abort);}
void write_string(const char *p_string, abort_callback &p_abort)
Helper function; writes string (with 32-bit header indicating length in bytes followed by UTF-8 encod...
Definition: filesystem.cpp:733
const char * stringToPtr(T const &val)
Definition: string_base.h:1018
void foobar2000_io::stream_writer::write_string_nullterm ( const char *  p_string,
abort_callback p_abort 
)
inline

Definition at line 195 of file filesystem.h.

195 {this->write( p_string, strlen(p_string)+1, p_abort); }
virtual void write(const void *p_buffer, t_size p_bytes, abort_callback &p_abort)=0
Writes specified number of bytes from specified buffer to the stream.
void stream_writer::write_string_raw ( const char *  p_string,
abort_callback p_abort 
)

Helper function; writes raw string to the stream, with no length info or null terminators.

Definition at line 737 of file filesystem.cpp.

737  {
738  write_object(p_string,strlen(p_string),p_abort);
739 }
void write_object(const void *p_buffer, t_size p_bytes, abort_callback &p_abort)
Helper. Same as write(), provided for consistency.
Definition: filesystem.h:170

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