ZED Open Capture  v0.6.0
Low level camera driver for the ZED stereo camera family
Public Member Functions | Protected Member Functions | List of all members
sl_oc::tools::SI_ConvertW< SI_CHAR > Class Template Reference

#include <calibration.hpp>

Public Member Functions

 SI_ConvertW (bool a_bStoreIsUtf8)
 
 SI_ConvertW (const SI_ConvertW &rhs)
 
SI_ConvertWoperator= (const SI_ConvertW &rhs)
 
size_t SizeFromStore (const char *a_pInputData, size_t a_uInputDataLen)
 
bool ConvertFromStore (const char *a_pInputData, size_t a_uInputDataLen, SI_CHAR *a_pOutputData, size_t a_uOutputDataSize)
 
size_t SizeToStore (const SI_CHAR *a_pInputData)
 
bool ConvertToStore (const SI_CHAR *a_pInputData, char *a_pOutputData, size_t a_uOutputDataSize)
 
 SI_ConvertW (bool a_bStoreIsUtf8)
 
 SI_ConvertW (const SI_ConvertW &rhs)
 
SI_ConvertWoperator= (const SI_ConvertW &rhs)
 
 ~SI_ConvertW ()
 
size_t SizeFromStore (const char *a_pInputData, size_t a_uInputDataLen)
 
bool ConvertFromStore (const char *a_pInputData, size_t a_uInputDataLen, UChar *a_pOutputData, size_t a_uOutputDataSize)
 
size_t SizeToStore (const UChar *a_pInputData)
 
bool ConvertToStore (const UChar *a_pInputData, char *a_pOutputData, size_t a_uOutputDataSize)
 
 SI_ConvertW (bool a_bStoreIsUtf8)
 
 SI_ConvertW (const SI_ConvertW &rhs)
 
SI_ConvertWoperator= (const SI_ConvertW &rhs)
 
size_t SizeFromStore (const char *a_pInputData, size_t a_uInputDataLen)
 
bool ConvertFromStore (const char *a_pInputData, size_t a_uInputDataLen, SI_CHAR *a_pOutputData, size_t a_uOutputDataSize)
 
size_t SizeToStore (const SI_CHAR *a_pInputData)
 
bool ConvertToStore (const SI_CHAR *a_pInputData, char *a_pOutputData, size_t a_uOutputDataSize)
 

Protected Member Functions

 SI_ConvertW ()
 
 SI_ConvertW ()
 
 SI_ConvertW ()
 

Detailed Description

template<class SI_CHAR>
class sl_oc::tools::SI_ConvertW< SI_CHAR >

Converts UTF-8 to a wchar_t (or equivalent) using the Unicode reference library functions. This can be used on all platforms.

Converts MBCS/UTF-8 to UChar using ICU. This can be used on all platforms.

Converts MBCS and UTF-8 to a wchar_t (or equivalent) on Windows. This uses only the Win32 functions and doesn't require the external Unicode UTF-8 conversion library. It will not work on Windows 95 without using Microsoft Layer for Unicode in your application.

Definition at line 3375 of file calibration.hpp.

Constructor & Destructor Documentation

◆ SI_ConvertW() [1/9]

template<class SI_CHAR >
sl_oc::tools::SI_ConvertW< SI_CHAR >::SI_ConvertW ( )
inlineprotected

Definition at line 3379 of file calibration.hpp.

3379  {
3380  }

◆ SI_ConvertW() [2/9]

template<class SI_CHAR >
sl_oc::tools::SI_ConvertW< SI_CHAR >::SI_ConvertW ( bool  a_bStoreIsUtf8)
inline

Definition at line 3383 of file calibration.hpp.

3383  : m_bStoreIsUtf8(a_bStoreIsUtf8) {
3384  }

◆ SI_ConvertW() [3/9]

template<class SI_CHAR >
sl_oc::tools::SI_ConvertW< SI_CHAR >::SI_ConvertW ( const SI_ConvertW< SI_CHAR > &  rhs)
inline

Definition at line 3387 of file calibration.hpp.

3387  {
3388  operator=(rhs);
3389  }
SI_ConvertW & operator=(const SI_ConvertW &rhs)

References sl_oc::tools::SI_ConvertW< SI_CHAR >::operator=().

◆ SI_ConvertW() [4/9]

template<class SI_CHAR >
sl_oc::tools::SI_ConvertW< SI_CHAR >::SI_ConvertW ( )
inlineprotected

Definition at line 3585 of file calibration.hpp.

3585  : m_pEncoding(NULL), m_pConverter(NULL) {
3586  }

◆ SI_ConvertW() [5/9]

template<class SI_CHAR >
sl_oc::tools::SI_ConvertW< SI_CHAR >::SI_ConvertW ( bool  a_bStoreIsUtf8)
inline

Definition at line 3589 of file calibration.hpp.

3589  : m_pConverter(NULL) {
3590  m_pEncoding = a_bStoreIsUtf8 ? "UTF-8" : NULL;
3591  }

◆ SI_ConvertW() [6/9]

template<class SI_CHAR >
sl_oc::tools::SI_ConvertW< SI_CHAR >::SI_ConvertW ( const SI_ConvertW< SI_CHAR > &  rhs)
inline

Definition at line 3594 of file calibration.hpp.

3594  {
3595  operator=(rhs);
3596  }

References sl_oc::tools::SI_ConvertW< SI_CHAR >::operator=().

◆ ~SI_ConvertW()

template<class SI_CHAR >
sl_oc::tools::SI_ConvertW< SI_CHAR >::~SI_ConvertW ( )
inline

Definition at line 3604 of file calibration.hpp.

3604  {
3605  if (m_pConverter) ucnv_close(m_pConverter);
3606  }

◆ SI_ConvertW() [7/9]

template<class SI_CHAR >
sl_oc::tools::SI_ConvertW< SI_CHAR >::SI_ConvertW ( )
inlineprotected

Definition at line 3815 of file calibration.hpp.

3815  {
3816  }

◆ SI_ConvertW() [8/9]

template<class SI_CHAR >
sl_oc::tools::SI_ConvertW< SI_CHAR >::SI_ConvertW ( bool  a_bStoreIsUtf8)
inline

Definition at line 3819 of file calibration.hpp.

3819  {
3820  m_uCodePage = a_bStoreIsUtf8 ? CP_UTF8 : CP_ACP;
3821  }

◆ SI_ConvertW() [9/9]

template<class SI_CHAR >
sl_oc::tools::SI_ConvertW< SI_CHAR >::SI_ConvertW ( const SI_ConvertW< SI_CHAR > &  rhs)
inline

Definition at line 3824 of file calibration.hpp.

3824  {
3825  operator=(rhs);
3826  }

References sl_oc::tools::SI_ConvertW< SI_CHAR >::operator=().

Member Function Documentation

◆ ConvertFromStore() [1/3]

template<class SI_CHAR >
bool sl_oc::tools::SI_ConvertW< SI_CHAR >::ConvertFromStore ( const char *  a_pInputData,
size_t  a_uInputDataLen,
SI_CHAR *  a_pOutputData,
size_t  a_uOutputDataSize 
)
inline

Convert the input string from the storage format to SI_CHAR. The storage format is always UTF-8 or MBCS.

Parameters
a_pInputDataData in storage format to be converted to SI_CHAR.
a_uInputDataLenLength of storage format data in bytes. This must be the actual length of the data, including NULL byte if NULL terminated string is required.
a_pOutputDataPointer to the output buffer to received the converted data.
a_uOutputDataSizeSize of the output buffer in SI_CHAR.
Returns
true if all of the input data was successfully converted.

Definition at line 3445 of file calibration.hpp.

3449  {
3450  if (m_bStoreIsUtf8) {
3451  // This uses the Unicode reference implementation to do the
3452  // conversion from UTF-8 to wchar_t. The required files are
3453  // ConvertUTF.h and ConvertUTF.c which should be included in
3454  // the distribution but are publically available from unicode.org
3455  // at http://www.unicode.org/Public/PROGRAMS/CVTUTF/
3456  ConversionResult retval;
3457  const UTF8 * pUtf8 = (const UTF8 *) a_pInputData;
3458  if (sizeof (wchar_t) == sizeof (UTF32)) {
3459  UTF32 * pUtf32 = (UTF32 *) a_pOutputData;
3460  retval = ConvertUTF8toUTF32(
3461  &pUtf8, pUtf8 + a_uInputDataLen,
3462  &pUtf32, pUtf32 + a_uOutputDataSize,
3464  } else if (sizeof (wchar_t) == sizeof (UTF16)) {
3465  UTF16 * pUtf16 = (UTF16 *) a_pOutputData;
3466  retval = ConvertUTF8toUTF16(
3467  &pUtf8, pUtf8 + a_uInputDataLen,
3468  &pUtf16, pUtf16 + a_uOutputDataSize,
3470  }
3471  return retval == conversionOK;
3472  }
3473 
3474  // convert to wchar_t
3475  size_t retval = mbstowcs(a_pOutputData,
3476  a_pInputData, a_uOutputDataSize);
3477  return retval != (size_t) (-1);
3478  }
unsigned char UTF8
ConversionResult ConvertUTF8toUTF16(const UTF8 **sourceStart, const UTF8 *sourceEnd, UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags)
ConversionResult ConvertUTF8toUTF32(const UTF8 **sourceStart, const UTF8 *sourceEnd, UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags)
unsigned int UTF32
unsigned short UTF16

References sl_oc::tools::conversionOK, sl_oc::tools::ConvertUTF8toUTF16(), sl_oc::tools::ConvertUTF8toUTF32(), and sl_oc::tools::lenientConversion.

◆ ConvertFromStore() [2/3]

template<class SI_CHAR >
bool sl_oc::tools::SI_ConvertW< SI_CHAR >::ConvertFromStore ( const char *  a_pInputData,
size_t  a_uInputDataLen,
SI_CHAR *  a_pOutputData,
size_t  a_uOutputDataSize 
)
inline

Convert the input string from the storage format to SI_CHAR. The storage format is always UTF-8 or MBCS.

Parameters
a_pInputDataData in storage format to be converted to SI_CHAR.
a_uInputDataLenLength of storage format data in bytes. This must be the actual length of the data, including NULL byte if NULL terminated string is required.
a_pOutputDataPointer to the output buffer to received the converted data.
a_uOutputDataSizeSize of the output buffer in SI_CHAR.
Returns
true if all of the input data was successfully converted.

Definition at line 3871 of file calibration.hpp.

3875  {
3876  int nSize = MultiByteToWideChar(
3877  m_uCodePage, 0,
3878  a_pInputData, (int) a_uInputDataLen,
3879  (wchar_t *) a_pOutputData, (int) a_uOutputDataSize);
3880  return (nSize > 0);
3881  }

◆ ConvertFromStore() [3/3]

template<class SI_CHAR >
bool sl_oc::tools::SI_ConvertW< SI_CHAR >::ConvertFromStore ( const char *  a_pInputData,
size_t  a_uInputDataLen,
UChar *  a_pOutputData,
size_t  a_uOutputDataSize 
)
inline

Convert the input string from the storage format to UChar. The storage format is always UTF-8 or MBCS.

Parameters
a_pInputDataData in storage format to be converted to UChar.
a_uInputDataLenLength of storage format data in bytes. This must be the actual length of the data, including NULL byte if NULL terminated string is required.
a_pOutputDataPointer to the output buffer to received the converted data.
a_uOutputDataSizeSize of the output buffer in UChar.
Returns
true if all of the input data was successfully converted.

Definition at line 3659 of file calibration.hpp.

3663  {
3664  UErrorCode nError;
3665 
3666  if (!m_pConverter) {
3667  nError = U_ZERO_ERROR;
3668  m_pConverter = ucnv_open(m_pEncoding, &nError);
3669  if (U_FAILURE(nError)) {
3670  return false;
3671  }
3672  }
3673 
3674  nError = U_ZERO_ERROR;
3675  ucnv_toUChars(m_pConverter,
3676  a_pOutputData, (int32_t) a_uOutputDataSize,
3677  a_pInputData, (int32_t) a_uInputDataLen, &nError);
3678  if (U_FAILURE(nError)) {
3679  return false;
3680  }
3681 
3682  return true;
3683  }

◆ ConvertToStore() [1/3]

template<class SI_CHAR >
bool sl_oc::tools::SI_ConvertW< SI_CHAR >::ConvertToStore ( const SI_CHAR *  a_pInputData,
char *  a_pOutputData,
size_t  a_uOutputDataSize 
)
inline

Convert the input string to the storage format of this data. The storage format is always UTF-8 or MBCS.

Parameters
a_pInputDataNULL terminated source string to convert. All of the data will be converted including the terminating NULL character.
a_pOutputDataPointer to the buffer to receive the converted string.
a_uOutputDataSizeSize of the output buffer in char.
Returns
true if all of the input data, including the terminating NULL character was successfully converted.

Definition at line 3521 of file calibration.hpp.

3525  {
3526  if (m_bStoreIsUtf8) {
3527  // calc input string length (SI_CHAR type and size independent)
3528  size_t uInputLen = 0;
3529  while (a_pInputData[uInputLen]) {
3530  ++uInputLen;
3531  }
3532  ++uInputLen; // include the NULL char
3533 
3534  // This uses the Unicode reference implementation to do the
3535  // conversion from wchar_t to UTF-8. The required files are
3536  // ConvertUTF.h and ConvertUTF.c which should be included in
3537  // the distribution but are publically available from unicode.org
3538  // at http://www.unicode.org/Public/PROGRAMS/CVTUTF/
3539  ConversionResult retval;
3540  UTF8 * pUtf8 = (UTF8 *) a_pOutputData;
3541  if (sizeof (wchar_t) == sizeof (UTF32)) {
3542  const UTF32 * pUtf32 = (const UTF32 *) a_pInputData;
3543  retval = ConvertUTF32toUTF8(
3544  &pUtf32, pUtf32 + uInputLen,
3545  &pUtf8, pUtf8 + a_uOutputDataSize,
3547  } else if (sizeof (wchar_t) == sizeof (UTF16)) {
3548  const UTF16 * pUtf16 = (const UTF16 *) a_pInputData;
3549  retval = ConvertUTF16toUTF8(
3550  &pUtf16, pUtf16 + uInputLen,
3551  &pUtf8, pUtf8 + a_uOutputDataSize,
3553  }
3554  return retval == conversionOK;
3555  } else {
3556  size_t retval = wcstombs(a_pOutputData,
3557  a_pInputData, a_uOutputDataSize);
3558  return retval != (size_t) - 1;
3559  }
3560  }
ConversionResult ConvertUTF16toUTF8(const UTF16 **sourceStart, const UTF16 *sourceEnd, UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags)
ConversionResult ConvertUTF32toUTF8(const UTF32 **sourceStart, const UTF32 *sourceEnd, UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags)

References sl_oc::tools::conversionOK, sl_oc::tools::ConvertUTF16toUTF8(), sl_oc::tools::ConvertUTF32toUTF8(), and sl_oc::tools::lenientConversion.

◆ ConvertToStore() [2/3]

template<class SI_CHAR >
bool sl_oc::tools::SI_ConvertW< SI_CHAR >::ConvertToStore ( const SI_CHAR *  a_pInputData,
char *  a_pOutputData,
size_t  a_uOutputDataSize 
)
inline

Convert the input string to the storage format of this data. The storage format is always UTF-8 or MBCS.

Parameters
a_pInputDataNULL terminated source string to convert. All of the data will be converted including the terminating NULL character.
a_pOutputDataPointer to the buffer to receive the converted string.
a_uOutputDataSizeSize of the output buffer in char.
Returns
true if all of the input data, including the terminating NULL character was successfully converted.

Definition at line 3915 of file calibration.hpp.

3918  {
3919  int retval = WideCharToMultiByte(
3920  m_uCodePage, 0,
3921  (const wchar_t *) a_pInputData, -1,
3922  a_pOutputData, (int) a_uOutputDataSize, 0, 0);
3923  return retval > 0;
3924  }

◆ ConvertToStore() [3/3]

template<class SI_CHAR >
bool sl_oc::tools::SI_ConvertW< SI_CHAR >::ConvertToStore ( const UChar *  a_pInputData,
char *  a_pOutputData,
size_t  a_uOutputDataSize 
)
inline

Convert the input string to the storage format of this data. The storage format is always UTF-8 or MBCS.

Parameters
a_pInputDataNULL terminated source string to convert. All of the data will be converted including the terminating NULL character.
a_pOutputDataPointer to the buffer to receive the converted string.
a_uOutputDataSizeSize of the output buffer in char.
Returns
true if all of the input data, including the terminating NULL character was successfully converted.

Definition at line 3730 of file calibration.hpp.

3733  {
3734  UErrorCode nError;
3735 
3736  if (!m_pConverter) {
3737  nError = U_ZERO_ERROR;
3738  m_pConverter = ucnv_open(m_pEncoding, &nError);
3739  if (U_FAILURE(nError)) {
3740  return false;
3741  }
3742  }
3743 
3744  nError = U_ZERO_ERROR;
3745  ucnv_fromUChars(m_pConverter,
3746  a_pOutputData, (int32_t) a_uOutputDataSize,
3747  a_pInputData, -1, &nError);
3748  if (U_FAILURE(nError)) {
3749  return false;
3750  }
3751 
3752  return true;
3753  }

◆ operator=() [1/3]

template<class SI_CHAR >
SI_ConvertW& sl_oc::tools::SI_ConvertW< SI_CHAR >::operator= ( const SI_ConvertW< SI_CHAR > &  rhs)
inline

Definition at line 3391 of file calibration.hpp.

3391  {
3392  m_bStoreIsUtf8 = rhs.m_bStoreIsUtf8;
3393  return *this;
3394  }

Referenced by sl_oc::tools::SI_ConvertW< SI_CHAR >::SI_ConvertW().

◆ operator=() [2/3]

template<class SI_CHAR >
SI_ConvertW& sl_oc::tools::SI_ConvertW< SI_CHAR >::operator= ( const SI_ConvertW< SI_CHAR > &  rhs)
inline

Definition at line 3598 of file calibration.hpp.

3598  {
3599  m_pEncoding = rhs.m_pEncoding;
3600  m_pConverter = NULL;
3601  return *this;
3602  }

◆ operator=() [3/3]

template<class SI_CHAR >
SI_ConvertW& sl_oc::tools::SI_ConvertW< SI_CHAR >::operator= ( const SI_ConvertW< SI_CHAR > &  rhs)
inline

Definition at line 3828 of file calibration.hpp.

3828  {
3829  m_uCodePage = rhs.m_uCodePage;
3830  return *this;
3831  }

◆ SizeFromStore() [1/3]

template<class SI_CHAR >
size_t sl_oc::tools::SI_ConvertW< SI_CHAR >::SizeFromStore ( const char *  a_pInputData,
size_t  a_uInputDataLen 
)
inline

Calculate the number of SI_CHAR required for converting the input from the storage format. The storage format is always UTF-8 or MBCS.

Parameters
a_pInputDataData in storage format to be converted to SI_CHAR.
a_uInputDataLenLength of storage format data in bytes. This must be the actual length of the data, including NULL byte if NULL terminated string is required.
Returns
Number of SI_CHAR required by the string when converted. If there are embedded NULL bytes in the input data, only the string up and not including the NULL byte will be converted.
-1 cast to size_t on a conversion error.

Definition at line 3409 of file calibration.hpp.

3411  {
3412  SI_ASSERT(a_uInputDataLen != (size_t) - 1);
3413 
3414  if (m_bStoreIsUtf8) {
3415  // worst case scenario for UTF-8 to wchar_t is 1 char -> 1 wchar_t
3416  // so we just return the same number of characters required as for
3417  // the source text.
3418  return a_uInputDataLen;
3419  }
3420 
3421 #if defined(SI_NO_MBSTOWCS_NULL) || (!defined(_MSC_VER) && !defined(_linux))
3422  // fall back processing for platforms that don't support a NULL dest to mbstowcs
3423  // worst case scenario is 1:1, this will be a sufficient buffer size
3424  (void) a_pInputData;
3425  return a_uInputDataLen;
3426 #else
3427  // get the actual required buffer size
3428  return mbstowcs(NULL, a_pInputData, a_uInputDataLen);
3429 #endif
3430  }

◆ SizeFromStore() [2/3]

template<class SI_CHAR >
size_t sl_oc::tools::SI_ConvertW< SI_CHAR >::SizeFromStore ( const char *  a_pInputData,
size_t  a_uInputDataLen 
)
inline

Calculate the number of UChar required for converting the input from the storage format. The storage format is always UTF-8 or MBCS.

Parameters
a_pInputDataData in storage format to be converted to UChar.
a_uInputDataLenLength of storage format data in bytes. This must be the actual length of the data, including NULL byte if NULL terminated string is required.
Returns
Number of UChar required by the string when converted. If there are embedded NULL bytes in the input data, only the string up and not including the NULL byte will be converted.
-1 cast to size_t on a conversion error.

Definition at line 3621 of file calibration.hpp.

3623  {
3624  SI_ASSERT(a_uInputDataLen != (size_t) - 1);
3625 
3626  UErrorCode nError;
3627 
3628  if (!m_pConverter) {
3629  nError = U_ZERO_ERROR;
3630  m_pConverter = ucnv_open(m_pEncoding, &nError);
3631  if (U_FAILURE(nError)) {
3632  return (size_t) - 1;
3633  }
3634  }
3635 
3636  nError = U_ZERO_ERROR;
3637  int32_t nLen = ucnv_toUChars(m_pConverter, NULL, 0,
3638  a_pInputData, (int32_t) a_uInputDataLen, &nError);
3639  if (U_FAILURE(nError) && nError != U_BUFFER_OVERFLOW_ERROR) {
3640  return (size_t) - 1;
3641  }
3642 
3643  return (size_t) nLen;
3644  }

◆ SizeFromStore() [3/3]

template<class SI_CHAR >
size_t sl_oc::tools::SI_ConvertW< SI_CHAR >::SizeFromStore ( const char *  a_pInputData,
size_t  a_uInputDataLen 
)
inline

Calculate the number of SI_CHAR required for converting the input from the storage format. The storage format is always UTF-8 or MBCS.

Parameters
a_pInputDataData in storage format to be converted to SI_CHAR.
a_uInputDataLenLength of storage format data in bytes. This must be the actual length of the data, including NULL byte if NULL terminated string is required.
Returns
Number of SI_CHAR required by the string when converted. If there are embedded NULL bytes in the input data, only the string up and not including the NULL byte will be converted.
-1 cast to size_t on a conversion error.

Definition at line 3846 of file calibration.hpp.

3848  {
3849  SI_ASSERT(a_uInputDataLen != (size_t) - 1);
3850 
3851  int retval = MultiByteToWideChar(
3852  m_uCodePage, 0,
3853  a_pInputData, (int) a_uInputDataLen,
3854  0, 0);
3855  return (size_t) (retval > 0 ? retval : -1);
3856  }

◆ SizeToStore() [1/3]

template<class SI_CHAR >
size_t sl_oc::tools::SI_ConvertW< SI_CHAR >::SizeToStore ( const SI_CHAR *  a_pInputData)
inline

Calculate the number of char required by the storage format of this data. The storage format is always UTF-8 or MBCS.

Parameters
a_pInputDataNULL terminated string to calculate the number of bytes required to be converted to storage format.
Returns
Number of bytes required by the string when converted to storage format. This size always includes space for the terminating NULL character.
-1 cast to size_t on a conversion error.

Definition at line 3490 of file calibration.hpp.

3491  {
3492  if (m_bStoreIsUtf8) {
3493  // worst case scenario for wchar_t to UTF-8 is 1 wchar_t -> 6 char
3494  size_t uLen = 0;
3495  while (a_pInputData[uLen]) {
3496  ++uLen;
3497  }
3498  return (6 * uLen) + 1;
3499  } else {
3500  size_t uLen = wcstombs(NULL, a_pInputData, 0);
3501  if (uLen == (size_t) (-1)) {
3502  return uLen;
3503  }
3504  return uLen + 1; // include NULL terminator
3505  }
3506  }

◆ SizeToStore() [2/3]

template<class SI_CHAR >
size_t sl_oc::tools::SI_ConvertW< SI_CHAR >::SizeToStore ( const SI_CHAR *  a_pInputData)
inline

Calculate the number of char required by the storage format of this data. The storage format is always UTF-8.

Parameters
a_pInputDataNULL terminated string to calculate the number of bytes required to be converted to storage format.
Returns
Number of bytes required by the string when converted to storage format. This size always includes space for the terminating NULL character.
-1 cast to size_t on a conversion error.

Definition at line 3893 of file calibration.hpp.

3894  {
3895  int retval = WideCharToMultiByte(
3896  m_uCodePage, 0,
3897  (const wchar_t *) a_pInputData, -1,
3898  0, 0, 0, 0);
3899  return (size_t) (retval > 0 ? retval : -1);
3900  }

◆ SizeToStore() [3/3]

template<class SI_CHAR >
size_t sl_oc::tools::SI_ConvertW< SI_CHAR >::SizeToStore ( const UChar *  a_pInputData)
inline

Calculate the number of char required by the storage format of this data. The storage format is always UTF-8 or MBCS.

Parameters
a_pInputDataNULL terminated string to calculate the number of bytes required to be converted to storage format.
Returns
Number of bytes required by the string when converted to storage format. This size always includes space for the terminating NULL character.
-1 cast to size_t on a conversion error.

Definition at line 3695 of file calibration.hpp.

3696  {
3697  UErrorCode nError;
3698 
3699  if (!m_pConverter) {
3700  nError = U_ZERO_ERROR;
3701  m_pConverter = ucnv_open(m_pEncoding, &nError);
3702  if (U_FAILURE(nError)) {
3703  return (size_t) - 1;
3704  }
3705  }
3706 
3707  nError = U_ZERO_ERROR;
3708  int32_t nLen = ucnv_fromUChars(m_pConverter, NULL, 0,
3709  a_pInputData, -1, &nError);
3710  if (U_FAILURE(nError) && nError != U_BUFFER_OVERFLOW_ERROR) {
3711  return (size_t) - 1;
3712  }
3713 
3714  return (size_t) nLen + 1;
3715  }

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