|
||||
File indexing completed on 2025-01-18 10:04:58
0001 // Copyright (c) 1998-1999 Matra Datavision 0002 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0003 // 0004 // This file is part of Open CASCADE Technology software library. 0005 // 0006 // This library is free software; you can redistribute it and/or modify it under 0007 // the terms of the GNU Lesser General Public License version 2.1 as published 0008 // by the Free Software Foundation, with special exception defined in the file 0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0010 // distribution for complete text of the license and disclaimer of any warranty. 0011 // 0012 // Alternatively, this file may be used under the terms of Open CASCADE 0013 // commercial license or contractual agreement. 0014 0015 //============================================================================ 0016 //==== Title: Standard_Character.hxx 0017 //==== Role : The header file of primitive type "Character" from package "Standard" 0018 //==== 0019 //==== Implementation: This is a primitive type implemented as typedef 0020 //==== typedef char Standard_Character 0021 //============================================================================ 0022 0023 #ifndef _Standard_Character_HeaderFile 0024 #define _Standard_Character_HeaderFile 0025 0026 #include <Standard_TypeDef.hxx> 0027 0028 #include <cctype> 0029 0030 // ------------------------------------------------------------------ 0031 // IsEqual : Returns Standard_True if two characters have the same value 0032 // ------------------------------------------------------------------ 0033 inline Standard_Boolean IsEqual(const Standard_Character One, 0034 const Standard_Character Two) 0035 { return One == Two; } 0036 0037 // =============================================== 0038 // Character classification functions 0039 // 0040 // NOTE: Character classification routines in C standard library 0041 // (isdigit(), isalpha() etc.) have integer argument instead of char. 0042 // Therefore if character from extended Ascii part of char table 0043 // (i.e. above 128) is passed into such functions it is converted 0044 // to int giving negative value (if characters are signed that 0045 // is default for most compilers). 0046 // It can be dangerous since implementation of these C functions 0047 // may use argument as index in the array without any checks 0048 // (for instance, in Microsoft VC++ -- see MSDN) 0049 // To avoid this, we cast char to unsigned char when passing to these functions. 0050 // =============================================== 0051 0052 // ================================================================== 0053 // IsAlphabetic : Returns Standard_True if a character is alphabetic 0054 // ================================================================== 0055 inline Standard_Boolean IsAlphabetic(const Standard_Character me) 0056 { return std::isalpha ((unsigned char)me) != 0; } 0057 0058 // ================================================================== 0059 // IsDigit : Returns Standard_True if a character is a digit 0060 // ================================================================== 0061 inline Standard_Boolean IsDigit(const Standard_Character me) 0062 { return std::isdigit ((unsigned char)me) != 0; } 0063 0064 // ================================================================== 0065 // IsXDigit : Returns Standard_True if a character is a digit 0066 // ================================================================== 0067 inline Standard_Boolean IsXDigit(const Standard_Character me) 0068 { return std::isxdigit((unsigned char)me) != 0; } 0069 0070 // ================================================================== 0071 // IsAlphanumeric : Returns Standard_True if a character is alphanumeric 0072 // ================================================================== 0073 inline Standard_Boolean IsAlphanumeric(const Standard_Character me) 0074 { return (IsAlphabetic(me) || IsDigit(me)) ; } 0075 0076 // ================================================================== 0077 // IsControl : Returns Standard_True if a character is a control character 0078 // ================================================================== 0079 inline Standard_Boolean IsControl(const Standard_Character me) 0080 { return std::iscntrl((unsigned char)me) != 0; } 0081 0082 0083 // ================================================================== 0084 // IsGraphic : Returns Standard_True if a character is graphic 0085 // ================================================================== 0086 inline Standard_Boolean IsGraphic(const Standard_Character me) 0087 { return std::isgraph((unsigned char)me) != 0; } 0088 0089 // ================================================================== 0090 // IsLowerCase : Returns Standard_True if a character is lowercase 0091 // ================================================================== 0092 inline Standard_Boolean IsLowerCase(const Standard_Character me) 0093 { return std::islower((unsigned char)me) != 0; } 0094 0095 // ================================================================== 0096 // IsPrintable : Returns Standard_True if a character is printable 0097 // ================================================================== 0098 inline Standard_Boolean IsPrintable(const Standard_Character me) 0099 { return std::isprint((unsigned char)me) != 0; } 0100 0101 // ================================================================== 0102 // IsPunctuation : Returns Standard_True if a character is a graphic and 0103 // not a alphanumeric character 0104 // ================================================================== 0105 inline Standard_Boolean IsPunctuation(const Standard_Character me) 0106 { return ( IsGraphic(me) && !IsAlphanumeric(me)); } 0107 0108 // ================================================================== 0109 // IsSpace : Returns Standard_True if a character is a space 0110 // ================================================================== 0111 inline Standard_Boolean IsSpace(const Standard_Character me) 0112 { return std::isspace((unsigned char)me) != 0; } 0113 0114 // ================================================================== 0115 // IsUppercase : Returns Standard_True if a character is uppercase 0116 // ================================================================== 0117 inline Standard_Boolean IsUpperCase(const Standard_Character me) 0118 { return std::isupper((unsigned char)me) != 0; } 0119 0120 // ================================================================== 0121 // LowerCase : Returns a lowercase character 0122 // ================================================================== 0123 inline Standard_Character LowerCase(const Standard_Character me) 0124 { return (Standard_Character)(unsigned char)std::tolower((unsigned char)me); } 0125 0126 // ================================================================== 0127 // UpperCase : Returns a uppercase character 0128 // ================================================================== 0129 inline Standard_Character UpperCase(const Standard_Character me) 0130 { return (Standard_Character)(unsigned char)std::toupper((unsigned char)me); } 0131 0132 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |