Ice 3.7 C++11 API Reference
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
Ice::OutputStream Class Reference

Interface for output streams used to create a sequence of bytes from Slice types. More...

#include <Ice/Ice.h>

Inheritance diagram for Ice::OutputStream:
Inheritance graph
[legend]
Collaboration diagram for Ice::OutputStream:
Collaboration graph
[legend]

Public Types

typedef size_t size_type
 

Public Member Functions

void clear ()
 Releases any data retained by encapsulations. More...
 
void endEncapsulation ()
 Ends the current encapsulation. More...
 
void endException ()
 Marks the end of an exception instance. More...
 
void endSize (size_type position)
 Updates the size value at the given position to contain a size based on the stream's current position. More...
 
void endSlice ()
 Marks the end of a value or exception slice. More...
 
void endValue ()
 Marks the end of a class instance. More...
 
std::pair< const Byte *, const Byte * > finished ()
 Indicates that marshaling is complete. More...
 
void finished (std::vector< Byte > &v)
 Indicates that marshaling is complete. More...
 
void * getClosure () const
 Obtains the closure data associated with this stream. More...
 
const EncodingVersiongetEncoding () const
 Determines the current encoding version. More...
 
void initialize (const CommunicatorPtr &communicator)
 Initializes the stream to use the communicator's default encoding version, class encoding format and string converters. More...
 
void initialize (const CommunicatorPtr &communicator, const EncodingVersion &version)
 Initializes the stream to use the given encoding version and the communicator's default class encoding format and string converters. More...
 
 OutputStream ()
 Constructs an OutputStream using the latest encoding version, the default format for class encoding, and the process string converters. More...
 
 OutputStream (const CommunicatorPtr &communicator)
 Constructs a stream using the communicator's default encoding version. More...
 
 OutputStream (const CommunicatorPtr &communicator, const EncodingVersion &version)
 Constructs a stream using the given communicator and encoding version. More...
 
 OutputStream (const CommunicatorPtr &communicator, const EncodingVersion &version, const std::pair< const Byte *, const Byte * > &bytes)
 Constructs a stream using the given communicator and encoding version. More...
 
size_type pos ()
 Obtains the current position of the stream. More...
 
void resize (Container::size_type sz)
 Resizes the stream to a new size. More...
 
void rewrite (Int v, size_type pos)
 Overwrite a 32-bit integer value at the given position in the stream. More...
 
void rewriteSize (Int v, Container::iterator dest)
 Replaces a size value at the given destination in the stream. More...
 
void * setClosure (void *p)
 Associates closure data with this stream. More...
 
void setFormat (FormatType format)
 Sets the class encoding format. More...
 
void startEncapsulation ()
 Writes the start of an encapsulation using the default encoding version and class encoding format. More...
 
void startEncapsulation (const EncodingVersion &encoding, FormatType format)
 Writes the start of an encapsulation using the given encoding version and class encoding format. More...
 
void startException (const SlicedDataPtr &data)
 Marks the start of an exception instance. More...
 
size_type startSize ()
 Writes a placeholder value for the size and returns the starting position of the size value; after writing the data, call endSize to patch the placeholder with the actual size at the given position. More...
 
void startSlice (const std::string &typeId, int compactId, bool last)
 Writes the start of a value or exception slice. More...
 
void startValue (const SlicedDataPtr &data)
 Marks the start of a class instance. More...
 
void swap (OutputStream &other)
 Swaps the contents of one stream with another. More...
 
void write (bool v)
 Writes a boolean to the stream. More...
 
void write (Byte v)
 Writes a byte to the stream. More...
 
template<typename T , typename ::std::enable_if<::std::is_base_of< ObjectPrx, T >::value >::type * = nullptr>
void write (const ::std::shared_ptr< T > &v)
 Writes a proxy to the stream. More...
 
template<typename T , typename ::std::enable_if<::std::is_base_of< Value, T >::value >::type * = nullptr>
void write (const ::std::shared_ptr< T > &v)
 Writes a value instance to the stream. More...
 
void write (const bool *begin, const bool *end)
 Writes a byte sequence to the stream. More...
 
void write (const Byte *start, const Byte *end)
 Writes a byte sequence to the stream. More...
 
void write (const char *vdata, bool convert=true)
 Writes a string to the stream. More...
 
void write (const char *vdata, size_t vsize, bool convert=true)
 Writes a string to the stream. More...
 
void write (const Double *begin, const Double *end)
 Writes a double sequence to the stream. More...
 
void write (const Float *begin, const Float *end)
 Writes a float sequence to the stream. More...
 
void write (const Int *begin, const Int *end)
 Writes an int sequence to the stream. More...
 
void write (const Long *begin, const Long *end)
 Writes a long sequence to the stream. More...
 
void write (const Short *begin, const Short *end)
 Writes a short sequence to the stream. More...
 
void write (const std::string &v, bool convert=true)
 Writes a string to the stream. More...
 
void write (const std::string *begin, const std::string *end, bool convert=true)
 Writes a string sequence to the stream. More...
 
void write (const std::vector< bool > &v)
 Writes a byte sequence to the stream. More...
 
template<typename T >
void write (const std::vector< T > &v)
 Writes a sequence of data values to the stream. More...
 
void write (const std::wstring &v)
 Writes a wide string to the stream. More...
 
void write (const std::wstring *begin, const std::wstring *end)
 Writes a wide string sequence to the stream. More...
 
template<typename T >
void write (const T &v)
 Writes a data value to the stream. More...
 
template<typename T >
void write (const T *begin, const T *end)
 Writes a sequence of data values to the stream. More...
 
void write (Double v)
 Writes a double to the stream. More...
 
void write (Float v)
 Writes a float to the stream. More...
 
template<typename T >
void write (Int tag, const IceUtil::Optional< T > &v)
 Writes an optional data value to the stream. More...
 
void write (Int v)
 Writes an int to the stream. More...
 
void write (Int v, Container::iterator dest)
 Overwrites a 32-bit integer value at the given destination in the stream. More...
 
void write (Long v)
 Writes a long to the stream. More...
 
void write (Short v)
 Writes a short to the stream. More...
 
template<typename T >
void writeAll (const T &v)
 Writes a list of mandatory data values. More...
 
template<typename T , typename... Te>
void writeAll (const T &v, const Te &... ve)
 Writes a list of mandatory data values. More...
 
template<size_t I = 0, typename... Te>
std::enable_if< I==sizeof...(Te), void >::type writeAll (std::tuple< Te... >)
 Writes a list of mandatory data values. More...
 
void writeBlob (const Byte *v, Container::size_type sz)
 Copies the specified blob of bytes to the stream without modification. More...
 
void writeBlob (const std::vector< Byte > &v)
 Copies the specified blob of bytes to the stream without modification. More...
 
void writeEmptyEncapsulation (const EncodingVersion &encoding)
 Writes an empty encapsulation using the given encoding version. More...
 
void writeEncapsulation (const Byte *v, Int sz)
 Copies the marshaled form of an encapsulation to the buffer. More...
 
void writeEnum (Int v, Int maxValue)
 Writes an enumerator to the stream. More...
 
void writeException (const UserException &v)
 Writes an exception to the stream. More...
 
template<size_t I = 0, typename... Te>
std::enable_if< I< sizeof...(Te), void >::type writeAll(std::tuple< Te... > tuple) { write(std::get< I >tuple));writeAll< I+1, Te... >tuple);} template< typename T > void writeAll(std::initializer_list< int > tags, const IceUtil::Optional< T > &v) { write(*(tags.begin()+tags.size() - 1), v);} template< typename T, typename... Te > void writeAll(std::initializer_list< int > tags, const IceUtil::Optional< T > &v, const IceUtil::Optional< Te > &... ve) { size_t index=tags.size() - sizeof...(ve) - 1;write(*(tags.begin()+index), v);writeAll(tags, ve...);} bool writeOptional(Int tag, OptionalFormat format) { assert(_currentEncaps);if(_currentEncaps->encoder) { return _currentEncaps-> encoder writeOptional (tag, format)
 Writes a list of mandatory data values. More...
 
void writePendingValues ()
 Encodes the state of class instances whose insertion was delayed during a previous call to write. More...
 
void writeProxy (const ::std::shared_ptr< ObjectPrx > &v)
 Writes a proxy to the stream. More...
 
void writeSize (Int v)
 Writes a size value. More...
 
 ~OutputStream ()
 

Public Attributes

 else
 

Detailed Description

Interface for output streams used to create a sequence of bytes from Slice types.

Member Typedef Documentation

◆ size_type

Constructor & Destructor Documentation

◆ OutputStream() [1/4]

Ice::OutputStream::OutputStream ( )

Constructs an OutputStream using the latest encoding version, the default format for class encoding, and the process string converters.

You can supply a communicator later by calling initialize().

◆ OutputStream() [2/4]

Ice::OutputStream::OutputStream ( const CommunicatorPtr &  communicator)

Constructs a stream using the communicator's default encoding version.

Parameters
communicatorThe communicator to use for marshaling tasks.

◆ OutputStream() [3/4]

Ice::OutputStream::OutputStream ( const CommunicatorPtr &  communicator,
const EncodingVersion version 
)

Constructs a stream using the given communicator and encoding version.

Parameters
communicatorThe communicator to use for marshaling tasks.
versionThe encoding version used to encode the data.

◆ OutputStream() [4/4]

Ice::OutputStream::OutputStream ( const CommunicatorPtr &  communicator,
const EncodingVersion version,
const std::pair< const Byte *, const Byte * > &  bytes 
)

Constructs a stream using the given communicator and encoding version.

Parameters
communicatorThe communicator to use for marshaling tasks.
versionThe encoding version used to encode the data.
bytesApplication-supplied memory that the stream uses as its initial marshaling buffer. The stream will reallocate if the size of the marshaled data exceeds the application's buffer.

◆ ~OutputStream()

Ice::OutputStream::~OutputStream ( )
inline

Member Function Documentation

◆ clear()

void Ice::OutputStream::clear ( )

Releases any data retained by encapsulations.

◆ endEncapsulation()

void Ice::OutputStream::endEncapsulation ( )
inline

Ends the current encapsulation.

◆ endException()

void Ice::OutputStream::endException ( )
inline

Marks the end of an exception instance.

◆ endSize()

void Ice::OutputStream::endSize ( size_type  position)
inline

Updates the size value at the given position to contain a size based on the stream's current position.

Parameters
positionThe starting position of the size value as returned by startSize.

◆ endSlice()

void Ice::OutputStream::endSlice ( )
inline

Marks the end of a value or exception slice.

◆ endValue()

void Ice::OutputStream::endValue ( )
inline

Marks the end of a class instance.

◆ finished() [1/2]

std::pair<const Byte*, const Byte*> Ice::OutputStream::finished ( )

Indicates that marshaling is complete.

This function must only be called once.

Returns
A pair of pointers into the internal marshaling buffer. These pointers are valid for the lifetime of the stream.

◆ finished() [2/2]

void Ice::OutputStream::finished ( std::vector< Byte > &  v)

Indicates that marshaling is complete.

This function must only be called once.

Parameters
vFilled with a copy of the encoded data.

◆ getClosure()

void* Ice::OutputStream::getClosure ( ) const

Obtains the closure data associated with this stream.

Returns
The data as a void pointer.

◆ getEncoding()

const EncodingVersion& Ice::OutputStream::getEncoding ( ) const
inline

Determines the current encoding version.

Returns
The encoding version.

◆ initialize() [1/2]

void Ice::OutputStream::initialize ( const CommunicatorPtr &  communicator)

Initializes the stream to use the communicator's default encoding version, class encoding format and string converters.

Use this method if you originally constructed the stream without a communicator.

Parameters
communicatorThe communicator to use for marshaling tasks.

◆ initialize() [2/2]

void Ice::OutputStream::initialize ( const CommunicatorPtr &  communicator,
const EncodingVersion version 
)

Initializes the stream to use the given encoding version and the communicator's default class encoding format and string converters.

Use this method if you originally constructed the stream without a communicator.

Parameters
communicatorThe communicator to use for marshaling tasks.
versionThe encoding version used to encode the data.

◆ pos()

size_type Ice::OutputStream::pos ( )
inline

Obtains the current position of the stream.

Returns
The current position.

◆ resize()

void Ice::OutputStream::resize ( Container::size_type  sz)
inline

Resizes the stream to a new size.

Parameters
szThe new size.

◆ rewrite()

void Ice::OutputStream::rewrite ( Int  v,
size_type  pos 
)
inline

Overwrite a 32-bit integer value at the given position in the stream.

This function does not change the stream's current position.

Parameters
vThe value to be written.
posThe buffer position for the value.

◆ rewriteSize()

void Ice::OutputStream::rewriteSize ( Int  v,
Container::iterator  dest 
)
inline

Replaces a size value at the given destination in the stream.

This function does not change the stream's current position.

Parameters
vA non-negative integer representing the size.
destThe buffer destination for the size.

◆ setClosure()

void* Ice::OutputStream::setClosure ( void *  p)

Associates closure data with this stream.

Parameters
pThe data as a void pointer.
Returns
The previous closure data, or nil.

◆ setFormat()

void Ice::OutputStream::setFormat ( FormatType  format)

Sets the class encoding format.

Parameters
formatThe encoding format.

◆ startEncapsulation() [1/2]

void Ice::OutputStream::startEncapsulation ( )

Writes the start of an encapsulation using the default encoding version and class encoding format.

◆ startEncapsulation() [2/2]

void Ice::OutputStream::startEncapsulation ( const EncodingVersion encoding,
FormatType  format 
)
inline

Writes the start of an encapsulation using the given encoding version and class encoding format.

Parameters
encodingThe encoding version to use for the encapsulation.
formatThe class format to use for the encapsulation.

◆ startException()

void Ice::OutputStream::startException ( const SlicedDataPtr &  data)
inline

Marks the start of an exception instance.

Parameters
dataContains the marshaled form of unknown slices from this instance. If not nil, these slices will be marshaled with the instance.

◆ startSize()

size_type Ice::OutputStream::startSize ( )
inline

Writes a placeholder value for the size and returns the starting position of the size value; after writing the data, call endSize to patch the placeholder with the actual size at the given position.

Returns
The starting position of the size value.

◆ startSlice()

void Ice::OutputStream::startSlice ( const std::string &  typeId,
int  compactId,
bool  last 
)
inline

Writes the start of a value or exception slice.

Parameters
typeIdThe Slice type ID for this slice.
compactIdThe compact ID corresponding to the type, or -1 if no compact ID is used.
lastTrue if this is the last slice, false otherwise.

◆ startValue()

void Ice::OutputStream::startValue ( const SlicedDataPtr &  data)
inline

Marks the start of a class instance.

Parameters
dataContains the marshaled form of unknown slices from this instance. If not nil, these slices will be marshaled with the instance.

◆ swap()

void Ice::OutputStream::swap ( OutputStream other)

Swaps the contents of one stream with another.

Parameters
otherThe other stream.

◆ write() [1/28]

void Ice::OutputStream::write ( bool  v)
inline

Writes a boolean to the stream.

Parameters
vThe boolean to write.

◆ write() [2/28]

void Ice::OutputStream::write ( Byte  v)
inline

Writes a byte to the stream.

Parameters
vThe byte to write.

◆ write() [3/28]

template<typename T , typename ::std::enable_if<::std::is_base_of< ObjectPrx, T >::value >::type * = nullptr>
void Ice::OutputStream::write ( const ::std::shared_ptr< T > &  v)
inline

Writes a proxy to the stream.

Parameters
vThe proxy to be written.

◆ write() [4/28]

template<typename T , typename ::std::enable_if<::std::is_base_of< Value, T >::value >::type * = nullptr>
void Ice::OutputStream::write ( const ::std::shared_ptr< T > &  v)
inline

Writes a value instance to the stream.

Parameters
vThe value to be written.

◆ write() [5/28]

void Ice::OutputStream::write ( const bool *  begin,
const bool *  end 
)

Writes a byte sequence to the stream.

Parameters
beginThe beginning of the sequence.
endThe end of the sequence.

◆ write() [6/28]

void Ice::OutputStream::write ( const Byte start,
const Byte end 
)

Writes a byte sequence to the stream.

Parameters
startThe beginning of the sequence.
endThe end of the sequence.

◆ write() [7/28]

void Ice::OutputStream::write ( const char *  vdata,
bool  convert = true 
)
inline

Writes a string to the stream.

Parameters
vdataThe null-terminated string to write.
convertDetermines whether the string is processed by the narrow string converter, if one has been configured. The default behavior is to convert the strings.

◆ write() [8/28]

void Ice::OutputStream::write ( const char *  vdata,
size_t  vsize,
bool  convert = true 
)
inline

Writes a string to the stream.

Parameters
vdataThe string to write.
vsizeThe size of the string.
convertDetermines whether the string is processed by the narrow string converter, if one has been configured. The default behavior is to convert the strings.

◆ write() [9/28]

void Ice::OutputStream::write ( const Double begin,
const Double end 
)

Writes a double sequence to the stream.

Parameters
beginThe beginning of the sequence.
endThe end of the sequence.

◆ write() [10/28]

void Ice::OutputStream::write ( const Float begin,
const Float end 
)

Writes a float sequence to the stream.

Parameters
beginThe beginning of the sequence.
endThe end of the sequence.

◆ write() [11/28]

void Ice::OutputStream::write ( const Int begin,
const Int end 
)

Writes an int sequence to the stream.

Parameters
beginThe beginning of the sequence.
endThe end of the sequence.

◆ write() [12/28]

void Ice::OutputStream::write ( const Long begin,
const Long end 
)

Writes a long sequence to the stream.

Parameters
beginThe beginning of the sequence.
endThe end of the sequence.

◆ write() [13/28]

void Ice::OutputStream::write ( const Short begin,
const Short end 
)

Writes a short sequence to the stream.

Parameters
beginThe beginning of the sequence.
endThe end of the sequence.

◆ write() [14/28]

void Ice::OutputStream::write ( const std::string &  v,
bool  convert = true 
)
inline

Writes a string to the stream.

Parameters
vThe string to write.
convertDetermines whether the string is processed by the narrow string converter, if one has been configured. The default behavior is to convert the strings.

◆ write() [15/28]

void Ice::OutputStream::write ( const std::string *  begin,
const std::string *  end,
bool  convert = true 
)

Writes a string sequence to the stream.

Parameters
beginThe beginning of the sequence.
endThe end of the sequence.
convertDetermines whether the string is processed by the narrow string converter, if one has been configured. The default behavior is to convert the strings.

◆ write() [16/28]

void Ice::OutputStream::write ( const std::vector< bool > &  v)

Writes a byte sequence to the stream.

Parameters
vThe sequence to be written.

◆ write() [17/28]

template<typename T >
void Ice::OutputStream::write ( const std::vector< T > &  v)
inline

Writes a sequence of data values to the stream.

Parameters
vThe sequence to be written.

◆ write() [18/28]

void Ice::OutputStream::write ( const std::wstring &  v)

Writes a wide string to the stream.

Parameters
vThe wide string to write.

◆ write() [19/28]

void Ice::OutputStream::write ( const std::wstring *  begin,
const std::wstring *  end 
)

Writes a wide string sequence to the stream.

Parameters
beginThe beginning of the sequence.
endThe end of the sequence.

◆ write() [20/28]

template<typename T >
void Ice::OutputStream::write ( const T &  v)
inline

Writes a data value to the stream.

Parameters
vThe data value to be written.

◆ write() [21/28]

template<typename T >
void Ice::OutputStream::write ( const T *  begin,
const T *  end 
)
inline

Writes a sequence of data values to the stream.

Parameters
beginThe beginning of the sequence.
endThe end of the sequence.

◆ write() [22/28]

void Ice::OutputStream::write ( Double  v)

Writes a double to the stream.

Parameters
vThe double to write.

◆ write() [23/28]

void Ice::OutputStream::write ( Float  v)

Writes a float to the stream.

Parameters
vThe float to write.

◆ write() [24/28]

template<typename T >
void Ice::OutputStream::write ( Int  tag,
const IceUtil::Optional< T > &  v 
)
inline

Writes an optional data value to the stream.

Parameters
tagThe tag ID.
vThe data value to be written (if any).

◆ write() [25/28]

void Ice::OutputStream::write ( Int  v)
inline

Writes an int to the stream.

Parameters
vThe int to write.

◆ write() [26/28]

void Ice::OutputStream::write ( Int  v,
Container::iterator  dest 
)
inline

Overwrites a 32-bit integer value at the given destination in the stream.

This function does not change the stream's current position.

Parameters
vThe integer value to be written.
destThe buffer destination for the integer value.

◆ write() [27/28]

void Ice::OutputStream::write ( Long  v)

Writes a long to the stream.

Parameters
vThe long to write.

◆ write() [28/28]

void Ice::OutputStream::write ( Short  v)

Writes a short to the stream.

Parameters
vThe short to write.

◆ writeAll() [1/3]

template<typename T >
void Ice::OutputStream::writeAll ( const T &  v)
inline

Writes a list of mandatory data values.

◆ writeAll() [2/3]

template<typename T , typename... Te>
void Ice::OutputStream::writeAll ( const T &  v,
const Te &...  ve 
)
inline

Writes a list of mandatory data values.

◆ writeAll() [3/3]

template<size_t I = 0, typename... Te>
std::enable_if<I == sizeof...(Te), void>::type Ice::OutputStream::writeAll ( std::tuple< Te... >  )
inline

Writes a list of mandatory data values.

◆ writeBlob() [1/2]

void Ice::OutputStream::writeBlob ( const Byte v,
Container::size_type  sz 
)
inline

Copies the specified blob of bytes to the stream without modification.

Parameters
vThe start of the buffer to be copied.
szThe number of bytes to be copied.

◆ writeBlob() [2/2]

void Ice::OutputStream::writeBlob ( const std::vector< Byte > &  v)

Copies the specified blob of bytes to the stream without modification.

Parameters
vThe bytes to be copied.

◆ writeEmptyEncapsulation()

void Ice::OutputStream::writeEmptyEncapsulation ( const EncodingVersion encoding)
inline

Writes an empty encapsulation using the given encoding version.

Parameters
encodingThe encoding version to use for the encapsulation.

◆ writeEncapsulation()

void Ice::OutputStream::writeEncapsulation ( const Byte v,
Int  sz 
)
inline

Copies the marshaled form of an encapsulation to the buffer.

Parameters
vThe start of the buffer.
szThe number of bytes to copy.

◆ writeEnum()

void Ice::OutputStream::writeEnum ( Int  v,
Int  maxValue 
)

Writes an enumerator to the stream.

Parameters
vThe enumerator to be written.
maxValueThe maximum value of all enumerators in this enumeration.

◆ writeException()

void Ice::OutputStream::writeException ( const UserException v)

Writes an exception to the stream.

Parameters
vThe exception to be written.

◆ writeOptional()

template<size_t I = 0, typename... Te>
std::enable_if<I < sizeof...(Te), void>::type writeAll(std::tuple<Te...> tuple) { write(std::get<I>tuple)); writeAll<I + 1, Te...>tuple); } template<typename T> void writeAll(std::initializer_list<int> tags, const IceUtil::Optional<T>& v) { write(*(tags.begin() + tags.size() - 1), v); } template<typename T, typename... Te> void writeAll(std::initializer_list<int> tags, const IceUtil::Optional<T>& v, const IceUtil::Optional<Te>&... ve) { size_t index = tags.size() - sizeof...(ve) - 1; write(*(tags.begin() + index), v); writeAll(tags, ve...); } bool writeOptional(Int tag, OptionalFormat format) { assert(_currentEncaps); if(_currentEncaps->encoder) { return _currentEncaps-> encoder Ice::OutputStream::writeOptional ( tag  ,
format   
)

Writes a list of mandatory data values.

◆ writePendingValues()

void Ice::OutputStream::writePendingValues ( )

Encodes the state of class instances whose insertion was delayed during a previous call to write.

This member function must only be called once. For backward compatibility with encoding version 1.0, this function must only be called when non-optional data members or parameters use class types.

◆ writeProxy()

void Ice::OutputStream::writeProxy ( const ::std::shared_ptr< ObjectPrx > &  v)

Writes a proxy to the stream.

Parameters
vThe proxy to be written.

◆ writeSize()

void Ice::OutputStream::writeSize ( Int  v)
inline

Writes a size value.

Parameters
vA non-negative integer.

Member Data Documentation

◆ else

Ice::OutputStream::else
Initial value:
{
return writeOptImpl(tag, format)

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