yum-mirror/VkFFT
git clone https://git.yummers.dev/yum-mirror/VkFFT
ba7001c
v1.3.2
1//------------------------------------------------------------------------------------------------------------------------------------------------------------- 2// 3// Foundation/NSString.hpp 4// 5// Copyright 2020-2021 Apple Inc. 6// 7// Licensed under the Apache License, Version 2.0 (the "License"); 8// you may not use this file except in compliance with the License. 9// You may obtain a copy of the License at 10// 11// http://www.apache.org/licenses/LICENSE-2.0 12// 13// Unless required by applicable law or agreed to in writing, software 14// distributed under the License is distributed on an "AS IS" BASIS, 15// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16// See the License for the specific language governing permissions and 17// limitations under the License. 18// 19//------------------------------------------------------------------------------------------------------------------------------------------------------------- 20 21#pragma once 22 23//------------------------------------------------------------------------------------------------------------------------------------------------------------- 24 25#include "NSDefines.hpp" 26#include "NSObject.hpp" 27#include "NSPrivate.hpp" 28#include "NSRange.hpp" 29#include "NSTypes.hpp" 30 31//------------------------------------------------------------------------------------------------------------------------------------------------------------- 32 33namespace NS 34{ 35_NS_ENUM ( NS :: UInteger , StringEncoding ) { 36ASCIIStringEncoding = 1 , 37NEXTSTEPStringEncoding = 2 , 38JapaneseEUCStringEncoding = 3 , 39UTF8StringEncoding = 4 , 40ISOLatin1StringEncoding = 5 , 41SymbolStringEncoding = 6 , 42NonLossyASCIIStringEncoding = 7 , 43ShiftJISStringEncoding = 8 , 44ISOLatin2StringEncoding = 9 , 45UnicodeStringEncoding = 10 , 46WindowsCP1251StringEncoding = 11 , 47WindowsCP1252StringEncoding = 12 , 48WindowsCP1253StringEncoding = 13 , 49WindowsCP1254StringEncoding = 14 , 50WindowsCP1250StringEncoding = 15 , 51ISO2022JPStringEncoding = 21 , 52MacOSRomanStringEncoding = 30 , 53 54UTF16StringEncoding = UnicodeStringEncoding , 55 56UTF16BigEndianStringEncoding = 0x90000100 , 57UTF16LittleEndianStringEncoding = 0x94000100 , 58 59UTF32StringEncoding = 0x8c000100 , 60UTF32BigEndianStringEncoding = 0x98000100 , 61UTF32LittleEndianStringEncoding = 0x9c000100 62} ; 63 64_NS_OPTIONS ( NS :: UInteger , StringCompareOptions ) { 65CaseInsensitiveSearch = 1 , 66LiteralSearch = 2 , 67BackwardsSearch = 4 , 68AnchoredSearch = 8 , 69NumericSearch = 64 , 70DiacriticInsensitiveSearch = 128 , 71WidthInsensitiveSearch = 256 , 72ForcedOrderingSearch = 512 , 73RegularExpressionSearch = 1024 74} ; 75 76using unichar = unsigned short ; 77 78class String : public Copying < String > 79{ 80public : 81static String * string () ; 82static String * string ( const String * pString ) ; 83static String * string ( const char * pString , StringEncoding encoding ) ; 84 85static String * alloc () ; 86String * init () ; 87String * init ( const String * pString ) ; 88String * init ( const char * pString , StringEncoding encoding ) ; 89String * init ( void * pBytes , UInteger len , StringEncoding encoding , bool freeBuffer ) ; 90 91unichar character ( UInteger index ) const ; 92UInteger length () const ; 93 94const char * cString ( StringEncoding encoding ) const ; 95const char * utf8String () const ; 96UInteger maximumLengthOfBytes ( StringEncoding encoding ) const ; 97UInteger lengthOfBytes ( StringEncoding encoding ) const ; 98 99bool isEqualToString ( const String * pString ) const ; 100Range rangeOfString ( const String * pString , StringCompareOptions options ) const ; 101 102const char * fileSystemRepresentation () const ; 103 104String * stringByAppendingString ( const String * pString ) const ; 105 106} ; 107 108template < std :: size_t _StringLen > 109constexpr const String * MakeConstantString ( const char ( & str )[ _StringLen ] ) 110{ 111return reinterpret_cast < const String * > ( __CFStringMakeConstantString ( str ) ) ; 112} 113 114} 115 116//------------------------------------------------------------------------------------------------------------------------------------------------------------- 117 118_NS_INLINE NS :: String * NS :: String :: string () 119{ 120return Object :: sendMessage < String *> ( _NS_PRIVATE_CLS ( NSString ) , _NS_PRIVATE_SEL ( string )) ; 121} 122 123//------------------------------------------------------------------------------------------------------------------------------------------------------------- 124 125_NS_INLINE NS :: String * NS :: String :: string ( const String * pString ) 126{ 127return Object :: sendMessage < String *> ( _NS_PRIVATE_CLS ( NSString ) , _NS_PRIVATE_SEL ( stringWithString_ ) , pString ) ; 128} 129 130//------------------------------------------------------------------------------------------------------------------------------------------------------------- 131 132_NS_INLINE NS :: String * NS :: String :: string ( const char * pString , StringEncoding encoding ) 133{ 134return Object :: sendMessage < String *> ( _NS_PRIVATE_CLS ( NSString ) , _NS_PRIVATE_SEL ( stringWithCString_encoding_ ) , pString , encoding ) ; 135} 136 137//------------------------------------------------------------------------------------------------------------------------------------------------------------- 138 139_NS_INLINE NS :: String * NS :: String :: alloc () 140{ 141return Object :: alloc < String > ( _NS_PRIVATE_CLS ( NSString )) ; 142} 143 144//------------------------------------------------------------------------------------------------------------------------------------------------------------- 145 146_NS_INLINE NS :: String * NS :: String :: init () 147{ 148return Object :: init < String > () ; 149} 150 151//------------------------------------------------------------------------------------------------------------------------------------------------------------- 152 153_NS_INLINE NS :: String * NS :: String :: init ( const String * pString ) 154{ 155return Object :: sendMessage < String *> ( this , _NS_PRIVATE_SEL ( initWithString_ ) , pString ) ; 156} 157 158//------------------------------------------------------------------------------------------------------------------------------------------------------------- 159 160_NS_INLINE NS :: String * NS :: String :: init ( const char * pString , StringEncoding encoding ) 161{ 162return Object :: sendMessage < String *> ( this , _NS_PRIVATE_SEL ( initWithCString_encoding_ ) , pString , encoding ) ; 163} 164 165//------------------------------------------------------------------------------------------------------------------------------------------------------------- 166 167_NS_INLINE NS :: String * NS :: String :: init ( void * pBytes , UInteger len , StringEncoding encoding , bool freeBuffer ) 168{ 169return Object :: sendMessage < String *> ( this , _NS_PRIVATE_SEL ( initWithBytesNoCopy_length_encoding_freeWhenDone_ ) , pBytes , len , encoding , freeBuffer ) ; 170} 171 172//------------------------------------------------------------------------------------------------------------------------------------------------------------- 173 174_NS_INLINE NS :: unichar NS :: String :: character ( UInteger index ) const 175{ 176return Object :: sendMessage < unichar > ( this , _NS_PRIVATE_SEL ( characterAtIndex_ ) , index ) ; 177} 178 179//------------------------------------------------------------------------------------------------------------------------------------------------------------- 180 181_NS_INLINE NS :: UInteger NS :: String :: length () const 182{ 183return Object :: sendMessage < UInteger > ( this , _NS_PRIVATE_SEL ( length )) ; 184} 185 186//------------------------------------------------------------------------------------------------------------------------------------------------------------- 187 188_NS_INLINE const char * NS :: String :: cString ( StringEncoding encoding ) const 189{ 190return Object :: sendMessage < const char *> ( this , _NS_PRIVATE_SEL ( cStringUsingEncoding_ ) , encoding ) ; 191} 192 193//------------------------------------------------------------------------------------------------------------------------------------------------------------- 194 195_NS_INLINE const char * NS :: String :: utf8String () const 196{ 197return Object :: sendMessage < const char *> ( this , _NS_PRIVATE_SEL ( UTF8String )) ; 198} 199 200//------------------------------------------------------------------------------------------------------------------------------------------------------------- 201 202_NS_INLINE NS :: UInteger NS :: String :: maximumLengthOfBytes ( StringEncoding encoding ) const 203{ 204return Object :: sendMessage < UInteger > ( this , _NS_PRIVATE_SEL ( maximumLengthOfBytesUsingEncoding_ ) , encoding ) ; 205} 206 207//------------------------------------------------------------------------------------------------------------------------------------------------------------- 208 209_NS_INLINE NS :: UInteger NS :: String :: lengthOfBytes ( StringEncoding encoding ) const 210{ 211return Object :: sendMessage < UInteger > ( this , _NS_PRIVATE_SEL ( lengthOfBytesUsingEncoding_ ) , encoding ) ; 212} 213 214//------------------------------------------------------------------------------------------------------------------------------------------------------------- 215 216_NS_INLINE bool NS :: String :: isEqualToString ( const NS :: String * pString ) const 217{ 218return Object :: sendMessage < bool > ( this , _NS_PRIVATE_SEL ( isEqualToString_ ) , pString ) ; 219} 220 221//------------------------------------------------------------------------------------------------------------------------------------------------------------- 222 223_NS_INLINE NS :: Range NS :: String :: rangeOfString ( const NS :: String * pString , NS :: StringCompareOptions options ) const 224{ 225return Object :: sendMessage < Range > ( this , _NS_PRIVATE_SEL ( rangeOfString_options_ ) , pString , options ) ; 226} 227 228//------------------------------------------------------------------------------------------------------------------------------------------------------------- 229 230 231//------------------------------------------------------------------------------------------------------------------------------------------------------------- 232 233_NS_INLINE const char * NS :: String :: fileSystemRepresentation () const 234{ 235return Object :: sendMessage < const char *> ( this , _NS_PRIVATE_SEL ( fileSystemRepresentation )) ; 236} 237 238//------------------------------------------------------------------------------------------------------------------------------------------------------------- 239 240_NS_INLINE NS :: String * NS :: String :: stringByAppendingString ( const String * pString ) const 241{ 242return Object :: sendMessage < NS :: String *> ( this , _NS_PRIVATE_SEL ( stringByAppendingString_ ) , pString ) ; 243} 244 245//-------------------------------------------------------------------------------------------------------------------------------------------------------------