1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

0027676: Foundation Classes - define Standard_ExtCharacter, Standard_Utf16Char using C++11 types char16_t

This commit is contained in:
kgv
2016-08-05 22:49:11 +03:00
committed by bugmaster
parent deb02f8655
commit c885cfda24
10 changed files with 62 additions and 56 deletions

View File

@@ -413,7 +413,7 @@ Storage_BaseDriver& DDF_IOStream::PutCharacter(const Standard_Character aValue)
Storage_BaseDriver& DDF_IOStream::PutExtCharacter(const Standard_ExtCharacter aValue)
{
*myOStream << aValue << " ";
*myOStream << (short )aValue << " ";
if (myOStream->bad()) Storage_StreamWriteError::Raise("PutExtCharacter");
return *this;
}
@@ -499,7 +499,9 @@ Storage_BaseDriver& DDF_IOStream::GetCharacter(Standard_Character& aValue)
Storage_BaseDriver& DDF_IOStream::GetExtCharacter(Standard_ExtCharacter& aValue)
{
if (!(*myIStream >> aValue)) Storage_StreamTypeMismatchError::Raise("GetExtCharacter");
short aChar = 0;
if (!(*myIStream >> aChar)) Storage_StreamTypeMismatchError::Raise("GetExtCharacter");
aValue = aChar;
return *this;
}

View File

@@ -447,7 +447,7 @@ Storage_BaseDriver& FSD_CmpFile::PutCharacter(const Standard_Character aValue)
Storage_BaseDriver& FSD_CmpFile::PutExtCharacter(const Standard_ExtCharacter aValue)
{
myStream << aValue << " ";
myStream << (short )aValue << " ";
if (myStream.bad()) Storage_StreamWriteError::Raise();
return *this;
}
@@ -539,8 +539,9 @@ Storage_BaseDriver& FSD_CmpFile::GetCharacter(Standard_Character& aValue)
Storage_BaseDriver& FSD_CmpFile::GetExtCharacter(Standard_ExtCharacter& aValue)
{
if (!(myStream >> aValue)) Storage_StreamTypeMismatchError::Raise();
short aChar = 0;
if (!(myStream >> aChar)) Storage_StreamTypeMismatchError::Raise();
aValue = aChar;
return *this;
}

View File

@@ -443,7 +443,7 @@ Storage_BaseDriver& FSD_File::PutCharacter(const Standard_Character aValue)
Storage_BaseDriver& FSD_File::PutExtCharacter(const Standard_ExtCharacter aValue)
{
myStream << aValue << " ";
myStream << (short )aValue << " ";
if (myStream.bad()) Storage_StreamWriteError::Raise();
return *this;
}
@@ -535,8 +535,9 @@ Storage_BaseDriver& FSD_File::GetCharacter(Standard_Character& aValue)
Storage_BaseDriver& FSD_File::GetExtCharacter(Standard_ExtCharacter& aValue)
{
if (!(myStream >> aValue)) Storage_StreamTypeMismatchError::Raise();
short aChar = 0;
if (!(myStream >> aChar)) Storage_StreamTypeMismatchError::Raise();
aValue = aChar;
return *this;
}

View File

@@ -19,6 +19,7 @@
#include <Standard_MMgrOpt.hxx>
#include <Standard_MMgrRaw.hxx>
#include <Standard_MMgrTBBalloc.hxx>
#include <Standard_Assert.hxx>
#include <stdlib.h>
#if(defined(_WIN32) || defined(__WIN32__))
@@ -80,6 +81,13 @@ Standard_MMgrFactory::Standard_MMgrFactory()
_configthreadlocale (-1);
#endif*/
// Check basic assumption.
// If assertion happens, then OCCT should be corrected for compatibility with such CPU architecture.
Standard_STATIC_ASSERT(sizeof(Standard_Utf8Char) == 1);
Standard_STATIC_ASSERT(sizeof(short) == 2);
Standard_STATIC_ASSERT(sizeof(Standard_Utf16Char) == 2);
Standard_STATIC_ASSERT(sizeof(Standard_Utf32Char) == 4);
char* aVar;
aVar = getenv ("MMGT_OPT");
Standard_Integer anAllocId = (aVar ? atoi (aVar): OCCT_MMGT_OPT_DEFAULT);

View File

@@ -17,16 +17,7 @@
#include <cstddef>
#include <ctime>
#if(defined(_MSC_VER) && (_MSC_VER < 1600))
// old MSVC - hasn't stdint header
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#endif
#include <stdint.h>
#if(defined(_MSC_VER) && (_MSC_VER < 1800))
// only Visual Studio 2013 (vc12) provides <cinttypes> header
@@ -61,21 +52,28 @@ typedef double Standard_Real;
typedef unsigned int Standard_Boolean;
typedef float Standard_ShortReal;
typedef char Standard_Character;
typedef short Standard_ExtCharacter;
typedef unsigned char Standard_Byte;
typedef void* Standard_Address;
typedef size_t Standard_Size;
typedef std::time_t Standard_Time;
//
typedef const char* Standard_CString;
typedef const short* Standard_ExtString;
// Unicode primitives, char16_t, char32_t
typedef char Standard_Utf8Char; //!< signed UTF-8 char
typedef unsigned char Standard_Utf8UChar; //!< unsigned UTF-8 char
typedef uint16_t Standard_Utf16Char; //!< UTF-16 char (always unsigned)
typedef uint32_t Standard_Utf32Char; //!< UTF-32 char (always unsigned)
#if (defined(__GNUC__) && !defined(__clang__) && ((__GNUC__ == 4 && __GNUC_MINOR__ <= 3) || __GNUC__ < 4))
// compatibility with old GCC compilers
typedef uint16_t Standard_ExtCharacter;
typedef uint16_t Standard_Utf16Char;
typedef uint32_t Standard_Utf32Char;
#else
typedef char16_t Standard_ExtCharacter;
typedef char16_t Standard_Utf16Char; //!< UTF-16 char (always unsigned)
typedef char32_t Standard_Utf32Char; //!< UTF-32 char (always unsigned)
#endif
typedef wchar_t Standard_WideChar; //!< wide char (unsigned UTF-16 on Windows platform and signed UTF-32 on Linux)
//
typedef const Standard_Character* Standard_CString;
typedef const Standard_ExtCharacter* Standard_ExtString;
#endif // _Standard_TypeDef_HeaderFile

View File

@@ -24,14 +24,21 @@
#include <cctype>
#include <cstdio>
static
Standard_PExtCharacter Allocate(const Standard_Size aLength);
static
Standard_PExtCharacter Reallocate(Standard_Address aAddr,
const Standard_Size aLength);
namespace
{
static Standard_PExtCharacter Allocate (const Standard_Size theLength)
{
return (Standard_PExtCharacter )Standard::Allocate (theLength);
}
Standard_EXPORT short NULL_EXTSTRING[1] = {0};
static Standard_PExtCharacter Reallocate (Standard_Address theAddr, const Standard_Size theLength)
{
return (Standard_PExtCharacter )Standard::Reallocate (theAddr, theLength);
}
static const Standard_ExtCharacter NULL_EXTSTRING[1] = {0};
}
//============================== input value have len = 2 bytes ====
inline Standard_ExtCharacter ConvertToUnicode2B (unsigned char *p)
@@ -817,7 +824,7 @@ Standard_Boolean TCollection_ExtendedString::ConvertToUnicode
(const Standard_CString aStr)
{
Standard_Boolean aRes = Standard_True;
short * p = mystring;
Standard_ExtCharacter* p = mystring;
int i = 0;
while (aStr[i] != '\0') {
if((aStr[i] & 0x80) == 0x00) //1byte => 1 symb - Lat1
@@ -904,24 +911,3 @@ Standard_Integer TCollection_ExtendedString::ToUTF8CString(Standard_PCharacter&
theCString[j] = 0x00;
return j;
}
//=======================================================================
//function : Allocate
//purpose :
//=======================================================================
Standard_PExtCharacter Allocate(const Standard_Size aLength)
{
Standard_PExtCharacter pChar;
//
pChar=(Standard_PExtCharacter)Standard::Allocate(aLength);
//
return pChar;
}
//=======================================================================
//function : Reallocate
//purpose :
//=======================================================================
Standard_PExtCharacter Reallocate(Standard_Address aAddr,
const Standard_Size aLength)
{
return (Standard_PExtCharacter)Standard::Reallocate(aAddr, aLength);
}