Stroika Library 3.0d25
 
Loading...
Searching...
No Matches
SDKChar.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2026. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Characters_SDKChar_h_
5#define _Stroika_Foundation_Characters_SDKChar_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include <type_traits>
10
11#if qStroika_Platform_Windows
12#include <tchar.h>
13#endif
14
15#include "Stroika/Foundation/Common/Common.h"
16
17/**
18 * Each platform SDK has its own policy for representing characters. Some use narrow characters (char),
19 * and a predefined code page (often configured via locale), and others use wide-characters (wchar_t unicode).
20 *
21 * SDKChar is the underlying representation of the SDK's characters - whether it be narrow or wide.
22 */
23
25
26 /**
27 * qStroika_Foundation_Characters_SDKUseswchar_t
28 *
29 * Defines if we use wchar_t or char for most platform interfaces (mostly applicable/useful for windows)
30 */
31#ifndef qStroika_Foundation_Characters_SDKUseswchar_t
32#if defined(qTargetPlatformSDKUseswchar_t)
33#define qStroika_Foundation_Characters_SDKUseswchar_t qTargetPlatformSDKUseswchar_t
34#elif (defined(_UNICODE) || defined(UNICODE))
35#define qStroika_Foundation_Characters_SDKUseswchar_t 1
36#else
37#define qStroika_Foundation_Characters_SDKUseswchar_t 0
38#endif
39#endif
40// DEPRECATED NAME - since 3.0d25 (to be removed in v3.0a1)
41#ifndef qTargetPlatformSDKUseswchar_t
42#define qTargetPlatformSDKUseswchar_t qStroika_Foundation_Characters_SDKUseswchar_t
43#endif
44
45// Then VALIDATE qStroika_Foundation_Characters_SDKUseswchar_t with respect to other common defines
46#if defined(_WINDOWS)
47#if qStroika_Foundation_Characters_SDKUseswchar_t
48#if !defined(_UNICODE) || !defined(UNICODE)
49#error "INCONSITENT VALS"
50#endif
51#else
52#if defined(_UNICODE) || defined(UNICODE)
53#error "INCONSITENT VALS"
54#endif
55#endif
56#endif
57
58 /**
59 * SDKChar is the kind of character passed to most/default platform SDK APIs.
60 *
61 * Platform-Specific Meaning:
62 * o Windows
63 * Typically this is wchar_t, which is char16_t-ish. Windows SDK also supports an older "A" API (active Code page single byte)
64 * which Stroika probably still supports, but this has not been tested in a while (not very useful, not used much anymore).
65 *
66 * o Unix
67 * There is no standard. This could be locale-dependent (often EUC based multibyte character sets).
68 * Or could be UTF-8. These aren't totally incompatible possibilities.
69 *
70 * o MacOS
71 * Same as 'Unix' above, but most typically UTF-8. So Stroika assumes UTF-8.
72 * See <https://stackoverflow.com/questions/3071377/saner-way-to-get-character-encoding-of-the-cli-in-mac-os-x>
73 *
74 * o Linux
75 * Same as 'Unix' above - default to assume locale{} based.
76 */
77 using SDKChar = conditional_t<qStroika_Foundation_Characters_SDKUseswchar_t, wchar_t, char>;
78
79}
80
81/*
82 ********************************************************************************
83 ***************************** Implementation Details ***************************
84 ********************************************************************************
85 */
86
87#include "SDKChar.inl"
88
89#endif /*_Stroika_Foundation_Characters_SDKChar_h_*/
conditional_t< qStroika_Foundation_Characters_SDKUseswchar_t, wchar_t, char > SDKChar
Definition SDKChar.h:77