0030344: Coding Rules - suppress GCC compiler warnings -Wstrict-overflow on Standard_...
[occt.git] / src / Standard / Standard_CString.hxx
CommitLineData
b311480e 1// Copyright (c) 1998-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
b311480e 14
3415763e 15//!@file Functions working with plain C strings
7fd59977 16
17#ifndef _Standard_CString_HeaderFile
18# define _Standard_CString_HeaderFile
19
07bbde45 20#include <Standard_Macro.hxx>
21
22# include <string.h>
23# include <stdio.h>
7fd59977 24
3415763e 25# if defined(_MSC_VER) && ! defined(strcasecmp)
7fd59977 26# define strcasecmp _stricmp
27# endif
28
07bbde45 29// C++ only definitions
30#ifdef __cplusplus
7fd59977 31
07bbde45 32#include <Standard_Integer.hxx>
33
34//! Returns bounded hash code for a null-terminated string, in range [1, theUpper]
68df8478 35Standard_EXPORT Standard_Integer HashCode (const Standard_CString theStr, const Standard_Integer theUpper);
7fd59977 36
07bbde45 37//! Returns 32-bit hash code for the first theLen characters in the string theStr
68df8478 38Standard_EXPORT Standard_Integer HashCodes (const Standard_CString theStr, const Standard_Integer theLen);
07bbde45 39
40//! Returns bounded hash code for the first theLen characters in
41//! the string theStr, in range [1, theUpper]
42inline Standard_Integer HashCode (const Standard_CString theStr,
43 const Standard_Integer theLen,
44 const Standard_Integer theUpper)
91322f44 45{
07bbde45 46// return (Abs( HashCodes( Value , Len ) ) % Upper ) + 1 ;
47 return HashCode (HashCodes (theStr, theLen), theUpper);
7fd59977 48}
49
07bbde45 50//! Returns Standard_True if two strings are equal
51inline Standard_Boolean IsEqual (const Standard_CString theOne, const Standard_CString theTwo)
7fd59977 52{
07bbde45 53 return strcmp (theOne, theTwo) == 0;
7fd59977 54}
55
07bbde45 56#endif /* __cplusplus */
57
58#ifdef __cplusplus
59extern "C" {
60#endif /* __cplusplus */
61
62//! Equivalent of standard C function atof() that always uses C locale
68df8478 63Standard_EXPORT double Atof (const char* theStr);
07bbde45 64
65//! Optimized equivalent of standard C function strtod() that always uses C locale
68df8478 66Standard_EXPORT double Strtod (const char* theStr, char** theNextPtr);
07bbde45 67
68//! Equivalent of standard C function printf() that always uses C locale
68df8478 69Standard_EXPORT int Printf (const char* theFormat, ...);
07bbde45 70
71//! Equivalent of standard C function fprintf() that always uses C locale
68df8478 72Standard_EXPORT int Fprintf (FILE* theFile, const char* theFormat, ...);
07bbde45 73
74//! Equivalent of standard C function sprintf() that always uses C locale
68df8478 75Standard_EXPORT int Sprintf (char* theBuffer, const char* theFormat, ...);
07bbde45 76
77#ifdef __cplusplus
7fd59977 78}
07bbde45 79#endif /* __cplusplus */
7fd59977 80
7fd59977 81#endif