qxLib
string_setup.h
Go to the documentation of this file.
1 /**
2 
3  @file string_setup.h
4  @author Khrapov
5  @date 10.06.2023
6  @copyright � Nick Khrapov, 2023. All right reserved.
7 
8 **/
9 #pragma once
10 
11 #include <qx/macros/config.h>
13 #include <qx/meta/tuple_utils.h>
14 
15 #define QX_ALL_CHAR_TYPES char, wchar_t
16 
17 #ifdef QX_CONF_USE_CHAR
18  #define QX_CONF_USE_WCHAR !QX_CONF_USE_CHAR
19 #elif defined(QX_CONF_USE_WCHAR)
20  #define QX_CONF_USE_CHAR !QX_CONF_USE_WCHAR
21 #elif !defined(QX_CONF_USE_CHAR) && !defined(QX_CONF_USE_WCHAR)
22  #define QX_CONF_USE_CHAR 0
23  #define QX_CONF_USE_WCHAR 1
24 #endif
25 
26 namespace qx::details
27 {
28 
29 using all_char_types = std::tuple<QX_ALL_CHAR_TYPES>;
30 
31 }
32 
33 
34 #if QX_CONF_USE_CHAR
35 
36  #define QX_CHAR_TYPE char
37  #define _QXT(quote) quote
38 
39 #elif QX_CONF_USE_WCHAR
40 
41  #define QX_CHAR_TYPE wchar_t
42  #define _QXT(quote) L##quote
43 
44  #if !defined(QX_CONF_UNICODE_MACRO)
45  #define QX_CONF_UNICODE_MACRO 1
46  #endif
47 
48  #if QX_CONF_UNICODE_MACRO && QX_WIN
49  #define UNICODE
50  #endif
51 
52 #endif
53 
54 #define QXT(quote) _QXT(quote)
55 
56 namespace qx
57 {
58 
59 using char_type = QX_CHAR_TYPE;
60 using forbidden_char_types = tuple_utils::remove_t<details::all_char_types, std::tuple<char_type>>;
61 
62 } // namespace qx
63 
64 #if !defined(QX_CONF_FORCE_STD_FORMAT) && __has_include("fmt/format.h")
65 
66 QX_PUSH_SUPPRESS_ALL_WARNINGS();
67  #define FMT_UNICODE 0
68  #define FMT_HEADER_ONLY 1
69  #include "fmt/format.h"
70  #include "fmt/xchar.h"
71 QX_POP_SUPPRESS_WARNINGS();
72  #define QX_FMT_NS fmt
73 #else
74 
75  #include <format>
76  #define QX_FMT_NS std
77 
78 #endif
Contains utils for working with std::tuple.