IWStringConverter Class Reference

An interface that supports conversion between simba_wstrings and other data types. More...

List of all members.

Public Member Functions

virtual bool ConvertFromASCIIString (const simba_char *in_asciiSourceBuffer, simba_int32 in_sourceLength, void *out_targetBuffer, simba_int32 in_targetLength, EncodingType in_targetEncoding, bool in_nullTerminate=true)=0
 Convert from ASCII string to target buffer with given encoding. The source buffer does not need to be NUL-terminated. The target buffer will be NUL-terminated if successful.
virtual simba_int32 ConvertFromWString (const void *in_sourceData, simba_uint32 in_sourceLength, simba_byte *in_buffer, simba_int32 in_bufferLength, EncodingType in_encoding, bool &out_truncated)=0
 Converts in_source into a string of encoding in_encoding.
virtual simba_int32 ConvertFromWString (const simba_wstring &in_source, simba_byte *in_buffer, simba_int32 in_bufferLength, EncodingType in_encoding, bool &out_truncated)=0
 Converts in_source into a string of encoding in_encoding.
virtual bool ConvertToASCIIString (const void *in_sourceBuffer, simba_int32 in_sourceLengthInBytes, EncodingType in_sourceEncoding, simba_char *out_asciiTargetBuffer, simba_int32 in_targetLength)=0
 Convert from source buffer in given encoding to an ASCII string. The source buffer does not need to be NUL-terminated. The target buffer will be NUL-terminated if successful.
virtual void ConvertToWString (const simba_byte *in_data, simba_int32 in_lengthInBytes, EncodingType in_encoding, simba_wstring &io_dest)=0
virtual simba_int32 GetLengthAsEncoding (const void *in_sourceData, simba_uint32 in_sourceLength, EncodingType in_encoding)=0
 Returns the number of bytes that the given string will take up once converted to the given encoding.
virtual simba_int32 GetLengthAsEncoding (const simba_wstring &in_source, EncodingType in_encoding)=0
 Returns the number of bytes that the given string will take up once converted to the given encoding.
virtual simba_signed_native GetNulTerminatedStringLength (const void *in_string, EncodingType in_encoding)=0
 Returns the length in bytes of the given NUL-terminated string in the given encoding.
virtual simba_int32 GetUpperBoundLengthAsEncoding (const void *in_sourceData, simba_uint32 in_sourceLength, EncodingType in_encoding)=0
 Returns the upper bound of the number bytes that the given string could take up once converted to the given encoding.
virtual simba_int32 GetUpperBoundLengthAsEncoding (const simba_wstring &in_source, EncodingType in_encoding)=0
 Returns the upper bound of the number bytes that the given string could take up once converted to the given encoding.
virtual ~IWStringConverter ()
 Destructor.

Protected Member Functions

 IWStringConverter ()
 Constructor.

Detailed Description

An interface that supports conversion between simba_wstrings and other data types.


Constructor & Destructor Documentation

virtual ~IWStringConverter (  )  [inline, virtual]

Destructor.

IWStringConverter (  )  [inline, protected]

Constructor.


Member Function Documentation

virtual bool ConvertFromASCIIString ( const simba_char in_asciiSourceBuffer,
simba_int32  in_sourceLength,
void *  out_targetBuffer,
simba_int32  in_targetLength,
EncodingType  in_targetEncoding,
bool  in_nullTerminate = true 
) [pure virtual]

Convert from ASCII string to target buffer with given encoding. The source buffer does not need to be NUL-terminated. The target buffer will be NUL-terminated if successful.

Parameters:
in_asciiSourceBuffer Pointer to array of ASCII characters. Does not need to have a NUL-terminator.
in_sourceLength Number of bytes in in_asciiSourceBuffer. This should not include a NUL-terminator.
out_targetBuffer Buffer to write converted result to. It is assumed this buffer is big enough to hold the NUL-terminated result. The buffer does not need to have space for the NUL terminator if in_nullTerminate is false.
in_targetLength Target buffer length in bytes.
in_targetEncoding Encoding to convert to.
in_nullTerminate Whether or not to NUL-terminate the resulting string.
Returns:
True if encoding was successful; false otherwise.
virtual simba_int32 ConvertFromWString ( const void *  in_sourceData,
simba_uint32  in_sourceLength,
simba_byte in_buffer,
simba_int32  in_bufferLength,
EncodingType  in_encoding,
bool &  out_truncated 
) [pure virtual]

Converts in_source into a string of encoding in_encoding.

in_source must point to a buffer encoded with simba_wstring::GetInternalEncoding().

The destination buffer is in_buffer, which has space for in_bufferLength bytes of data. out_truncated is set to true if there is not enough space in in_buffer for the whole string. No special NUL termination is performed.

If in_bufferLength is greater than or equal to GetUpperBoundLengthAsEncoding and the conversion is supported then a faster string conversion method will be used.

Parameters:
in_sourceData Source string data. (NOT OWN)
in_sourceLength Length of in_sourceData in UTF-16 code units.
in_buffer Destination buffer
in_bufferLength Size of destination buffer, in bytes
in_encoding Desired encoding of converted data
out_truncated Set to true if truncation occurs, false if it doesn't
Returns:
The number of bytes of the buffer the resulting string takes up. Only meaningful if no truncation took place.
virtual simba_int32 ConvertFromWString ( const simba_wstring in_source,
simba_byte in_buffer,
simba_int32  in_bufferLength,
EncodingType  in_encoding,
bool &  out_truncated 
) [pure virtual]

Converts in_source into a string of encoding in_encoding.

The destination buffer is in_buffer, which has space for in_bufferLength bytes of data. out_truncated is set to true if there is not enough space in in_buffer for the whole string. No special NUL termination is performed.

If in_bufferLength is greater than or equal to GetUpperBoundLengthAsEncoding and the conversion is supported then a faster string conversion method will be used.

Parameters:
in_source Source string
in_buffer Destination buffer
in_bufferLength Size of destination buffer, in bytes
in_encoding Desired encoding of converted data
out_truncated Set to true if truncation occurs, false if it doesn't
Returns:
The number of bytes of the buffer the resulting string takes up. Only meaningful if no truncation took place.
virtual bool ConvertToASCIIString ( const void *  in_sourceBuffer,
simba_int32  in_sourceLengthInBytes,
EncodingType  in_sourceEncoding,
simba_char out_asciiTargetBuffer,
simba_int32  in_targetLength 
) [pure virtual]

Convert from source buffer in given encoding to an ASCII string. The source buffer does not need to be NUL-terminated. The target buffer will be NUL-terminated if successful.

Parameters:
in_sourceBuffer Source buffer. Does not need to have a NUL-terminator.
in_sourceLengthInBytes Number of bytes in the source buffer. This should not include a NUL-terminator.
in_sourceEncoding Encoding of source buffer.
out_asciiTargetBuffer Target buffer, will be ASCII encoded and NUL-terminated.
in_targetLength Number of bytes in target buffer.
Returns:
True if encoding was successful; false otherwise.
virtual void ConvertToWString ( const simba_byte in_data,
simba_int32  in_lengthInBytes,
EncodingType  in_encoding,
simba_wstring io_dest 
) [pure virtual]

Converts in_data, of length in_length and encoding in_encoding, into io_dest.

Parameters:
in_data Source data
in_lengthInBytes Length of in_source in bytes, or SIMBA_NTS if NUL-terminated (where the NUL is encoded for in_encoding).
in_encoding Encoding of in_source
io_dest Destination string
virtual simba_int32 GetLengthAsEncoding ( const void *  in_sourceData,
simba_uint32  in_sourceLength,
EncodingType  in_encoding 
) [pure virtual]

Returns the number of bytes that the given string will take up once converted to the given encoding.

in_source must point to a buffer encoded with simba_wstring::GetInternalEncoding().

Space is not included for an extra NUL terminator at the end.

Parameters:
in_sourceData Source string data. (NOT OWN)
in_sourceLength Length of in_sourceData in UTF-16 code units.
in_encoding Destination encoding
virtual simba_int32 GetLengthAsEncoding ( const simba_wstring in_source,
EncodingType  in_encoding 
) [pure virtual]

Returns the number of bytes that the given string will take up once converted to the given encoding.

Space is not included for an extra NUL terminator at the end.

Parameters:
in_source Source string
in_encoding Destination encoding
virtual simba_signed_native GetNulTerminatedStringLength ( const void *  in_string,
EncodingType  in_encoding 
) [pure virtual]

Returns the length in bytes of the given NUL-terminated string in the given encoding.

Parameters:
in_string 
in_encoding 
virtual simba_int32 GetUpperBoundLengthAsEncoding ( const void *  in_sourceData,
simba_uint32  in_sourceLength,
EncodingType  in_encoding 
) [pure virtual]

Returns the upper bound of the number bytes that the given string could take up once converted to the given encoding.

This function can be much faster than getting the real length as it shouldn't need to look at the string.

in_source must point to a buffer encoded with simba_wstring::GetInternalEncoding().

Space is not included for an extra NUL terminator at the end.

Parameters:
in_sourceData Source string data. (NOT OWN)
in_sourceLength Length of in_sourceData in UTF-16 code units.
in_encoding Destination encoding
virtual simba_int32 GetUpperBoundLengthAsEncoding ( const simba_wstring in_source,
EncodingType  in_encoding 
) [pure virtual]

Returns the upper bound of the number bytes that the given string could take up once converted to the given encoding.

This function can be much faster than getting the real length as it shouldn't need to look at the string.

Space is not included for an extra NUL terminator at the end.

Parameters:
in_source Source string
in_encoding Destination encoding

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