IWStreamConverter Class Reference

IWStreamConverter is used to stream convert data from one wide string encoding to another. More...

List of all members.

Public Member Functions

virtual bool CanConvert (EncodingType in_sourceEnc, EncodingType in_targetEnc)=0
 Indicates if the converter can be used with the specified source and target encodings. The caller should ReInitialize() the converter before calling SetSource() or SetTarget().
virtual simba_int32 Convert (bool in_flush)=0
 Converts data from the source buffer (including any partial character data left over from the previous source buffer) into the target buffer (including any partial character data which didn't fit into the previous target buffer).
virtual bool HasTargetDataLeft ()=0
 Indicates if there is any data left to write into a target buffer. If data has already been written into the current buffer it doesn't count.
virtual void ReInitialize ()=0
 Re-initializes the object, allowing it to be reused for another conversion.
virtual void SetSource (const simba_byte *in_sourceBuffer, simba_signed_native in_sourceLength)=0
 Sets a next source buffer to convert data from.
virtual void SetTarget (simba_byte *in_targetBuffer, simba_signed_native in_targetLength)=0
 Sets the next target buffer to convert data into.
virtual ~IWStreamConverter ()
 Destructor.

Protected Member Functions

 IWStreamConverter ()
 Constructor.

Detailed Description

IWStreamConverter is used to stream convert data from one wide string encoding to another.


Constructor & Destructor Documentation

virtual ~IWStreamConverter (  )  [inline, virtual]

Destructor.

IWStreamConverter (  )  [inline, protected]

Constructor.


Member Function Documentation

virtual bool CanConvert ( EncodingType  in_sourceEnc,
EncodingType  in_targetEnc 
) [pure virtual]

Indicates if the converter can be used with the specified source and target encodings. The caller should ReInitialize() the converter before calling SetSource() or SetTarget().

Parameters:
in_sourceEnc The source encoding.
in_targetEnc The target encoding.
Returns:
True if this IWStreamConverter can be used to convert in_sourceEnc in_targetEnc
virtual simba_int32 Convert ( bool  in_flush  )  [pure virtual]

Converts data from the source buffer (including any partial character data left over from the previous source buffer) into the target buffer (including any partial character data which didn't fit into the previous target buffer).

If in_flush is true or the target buffer has been filled up during the conversion, then the return value of this method is the total number of bytes written to the target buffer, not including bytes used for a possible NUL terminator.

If in_flush is false, the entire source buffer has been processed, and the target buffer hasn't been filled up, then the return value of this method is SOURCE_FINISHED. If there is more data available, then SetSource() should be called to provide it to the converter. If there is no more data available, then Convert() should be called with in_flush = true in order to get the length for the data that has partly filled up the final target buffer.

Calling Convert() without setting a new source and/or target buffer as appropriate will result in the same return value as the previous call.

Throws an ErrorException if the source and target buffers haven't been set.

Usage example:

  • Create a IWStreamConverter* called converter.
  • converter->SetSource(sourceDataChunk1, sourceLength1)
  • converter->SetTarget(targetDataChunk1, targetLength1)
  • 156 = converter->Convert(false)
    • So our first target buffer is full, and 156 bytes of data was written
  • converter->SetTarget(targetDataChunk2, targetLength2)
  • SOURCE_FINISHED = converter->Convert(false)
    • So we've finished with the first source chunk and the target isn't full yet
  • converter->SetSource(sourceDataChunk2, sourceLength2)
  • 124 = converter->Convert(false)
  • converter->SetTarget(targetDataChunk3, targetLength3)
  • SOURCE_FINISHED = converter->Convert(false)
    • But we have no more source data left
  • 15 = converter->Convert(true)
    • So there has been 15 bytes written to targetDataChunk3.
Parameters:
in_flush Indicates if the converter should flush.
Returns:
The number of bytes converted, or SOURCE_FINISHED if the source buffer has been consumed and in_flush was false.
virtual bool HasTargetDataLeft (  )  [pure virtual]

Indicates if there is any data left to write into a target buffer. If data has already been written into the current buffer it doesn't count.

If data has already been written to the target buffer but you don't know the length yet because it's full and you have no more source data, call Convert(in_flush=true) to get the length of data written.

Returns:
True if there is data left to write into the target buffer.
virtual void ReInitialize (  )  [pure virtual]

Re-initializes the object, allowing it to be reused for another conversion.

virtual void SetSource ( const simba_byte in_sourceBuffer,
simba_signed_native  in_sourceLength 
) [pure virtual]

Sets a next source buffer to convert data from.

Throws an ErrorException if the current source buffer has not been fully converted yet, the buffer is NULL or the length is negative.

Parameters:
in_sourceBuffer Buffer of wide string data encoded according to the source encoding for the converter.
in_sourceLength Size of in_sourceBuffer in bytes.
Exceptions:
ErrorException if the current source buffer has not been fully converted yet, the buffer is NULL or the length is negative.
virtual void SetTarget ( simba_byte in_targetBuffer,
simba_signed_native  in_targetLength 
) [pure virtual]

Sets the next target buffer to convert data into.

Throws an ErrorException if the current target buffer has not been filled yet, the buffer is NULL or the length is negative or 0.

Parameters:
in_targetBuffer Buffer in which to hold converted wide string data according to the target encoding for the converter.
in_targetLength Length of in_targetBuffer in bytes.

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

Generated on Wed May 17 14:21:19 2017 for SimbaEngine 10.1.3.1011 by simba