mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-06-13 10:49:16 +08:00
0024574: ICC compiler warnings on Windows
NCollection_UtfString and NCollection_UtfIterator classes are refactored to use methods overloading instead of switches to dispatch implementation depending on character (Unicode code unit) size. ICC-specific preprocessor directives are added to avoid warnings. Unused local functions and variables, class methods, unreachable statements, and extra throw() declarations reported by ICC are removed. Usage of "expl" for name of local variable is avoided as it conflicts with standard C function "expl" defined in math.h as preprocessor macro. Non-standard (MS-specific) argument envp is removed in definition of main() function on Windows. Functions _main_ and _WinMain_ are renamed to Draw_Main and Draw_WinMain, respectively, to avoid using names reserved in C++. Doxygen warning is fixed in XDE User's Guide.
This commit is contained in:
@@ -13,53 +13,6 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
// =======================================================================
|
||||
// function : strGetAdvance
|
||||
// purpose : Compute advance for specified string.
|
||||
// =======================================================================
|
||||
template<typename TypeTo> template<typename TypeFrom> inline
|
||||
void NCollection_UtfString<TypeTo>::strGetAdvance (const TypeFrom* theStringUtf,
|
||||
const Standard_Integer theLengthMax,
|
||||
Standard_Integer& theSizeBytes,
|
||||
Standard_Integer& theLength)
|
||||
{
|
||||
theSizeBytes = 0;
|
||||
theLength = 0;
|
||||
NCollection_UtfIterator<TypeFrom> anIter (theStringUtf);
|
||||
const Standard_Integer aLengthMax = (theLengthMax > 0) ? theLengthMax : IntegerLast();
|
||||
switch (sizeof(TypeTo))
|
||||
{
|
||||
case sizeof(Standard_Utf8Char):
|
||||
{
|
||||
for (; *anIter != 0 && anIter.Index() < aLengthMax; ++anIter)
|
||||
{
|
||||
theSizeBytes += anIter.AdvanceBytesUtf8();
|
||||
}
|
||||
theLength = anIter.Index();
|
||||
return;
|
||||
}
|
||||
case sizeof(Standard_Utf16Char):
|
||||
{
|
||||
for (; *anIter != 0 && anIter.Index() < aLengthMax; ++anIter)
|
||||
{
|
||||
theSizeBytes += anIter.AdvanceBytesUtf16();
|
||||
}
|
||||
theLength = anIter.Index();
|
||||
return;
|
||||
}
|
||||
case sizeof(Standard_Utf32Char):
|
||||
{
|
||||
for (; *anIter != 0 && anIter.Index() < aLengthMax; ++anIter)
|
||||
{
|
||||
theSizeBytes += anIter.AdvanceBytesUtf32();
|
||||
}
|
||||
theLength = anIter.Index();
|
||||
return;
|
||||
}
|
||||
default: return;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetChar
|
||||
// purpose :
|
||||
@@ -225,55 +178,6 @@ const NCollection_UtfString<Type>& NCollection_UtfString<Type>::operator= (const
|
||||
return (*this);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : FromUnicode
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
template<typename Type> template<typename TypeFrom>
|
||||
void NCollection_UtfString<Type>::FromUnicode (const TypeFrom* theStringUtf,
|
||||
const Standard_Integer theLength)
|
||||
{
|
||||
Type* anOldBuffer = myString; // necessary in case of self-copying
|
||||
NCollection_UtfIterator<TypeFrom> anIterRead (theStringUtf);
|
||||
if (*anIterRead == 0)
|
||||
{
|
||||
// special case
|
||||
Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (sizeof(TypeFrom)) // use switch() rather than if() to shut up msvc compiler
|
||||
{
|
||||
case sizeof(Type):
|
||||
{
|
||||
if (theLength > 0)
|
||||
{
|
||||
// optimized copy
|
||||
for(; *anIterRead != 0 && anIterRead.Index() < theLength; ++anIterRead) {}
|
||||
|
||||
mySize = Standard_Integer((Standard_Byte* )anIterRead.BufferHere() - (Standard_Byte* )theStringUtf);
|
||||
myLength = anIterRead.Index();
|
||||
myString = strAlloc (mySize);
|
||||
strCopy ((Standard_Byte* )myString, (const Standard_Byte* )theStringUtf, mySize);
|
||||
strFree (anOldBuffer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
|
||||
strGetAdvance (theStringUtf, theLength, mySize, myLength);
|
||||
myString = strAlloc (mySize);
|
||||
// reset iterator
|
||||
anIterRead.Init (theStringUtf);
|
||||
Type* anIterWrite = myString;
|
||||
for (; *anIterRead != 0 && anIterRead.Index() < myLength; ++anIterRead)
|
||||
{
|
||||
anIterWrite = anIterRead.GetUtf (anIterWrite);
|
||||
}
|
||||
strFree (anOldBuffer);
|
||||
}
|
||||
|
||||
#if !defined(__ANDROID__)
|
||||
//! Auxiliary convertion tool.
|
||||
class NCollection_UtfStringTool
|
||||
|
||||
Reference in New Issue
Block a user