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 
16 #define QX_CHAR_T_CHAR 0
17 #define QX_CHAR_T_WCHAR_T 1
18 
19 #ifndef QX_CONF_CHAR
20  #define QX_CONF_CHAR QX_CHAR_T_WCHAR_T
21 #endif
22 
23 
24 #define QX_FMT_LIB_FMT 0
25 #define QX_FMT_LIB_STD 1
26 
27 #ifndef QX_CONF_FMT_LIB
28  #if __has_include("fmt/format.h")
29  #define QX_CONF_FMT_LIB QX_FMT_LIB_FMT
30  #else
31  #define QX_CONF_FMT_LIB QX_FMT_LIB_STD
32  #endif
33 #endif
34 
35 
36 #define QX_ALL_CHAR_TYPES char, wchar_t
37 
38 namespace qx::details
39 {
40 
41 using all_char_types = std::tuple<QX_ALL_CHAR_TYPES>;
42 
43 }
44 
45 
46 #if QX_CONF_CHAR == QX_CHAR_T_CHAR
47  #define QX_CHAR_TYPE char
48  #define _QXT(quote) quote
49 #elif QX_CONF_CHAR == QX_CHAR_T_WCHAR_T
50  #define QX_CHAR_TYPE wchar_t
51  #define _QXT(quote) L##quote
52 
53  #if !defined(QX_CONF_UNICODE_MACRO)
54  #define QX_CONF_UNICODE_MACRO 1
55  #endif
56 
57  #if QX_CONF_UNICODE_MACRO && QX_WIN
58  #define UNICODE
59  #endif
60 #else
61  #error Unsupported char type
62 #endif
63 
64 #define QXT(quote) _QXT(quote)
65 
66 namespace qx
67 {
68 
69 using char_type = QX_CHAR_TYPE;
70 using forbidden_char_types = tuple_utils::remove_t<details::all_char_types, std::tuple<char_type>>;
71 
72 } // namespace qx
73 
74 #if QX_CONF_FMT_LIB == QX_FMT_LIB_FMT
75 QX_PUSH_SUPPRESS_ALL_WARNINGS();
76  #define FMT_UNICODE 0
77  #define FMT_HEADER_ONLY 1
78  #include "fmt/format.h"
79  #include "fmt/xchar.h"
80 QX_POP_SUPPRESS_WARNINGS();
81  #define QX_FMT_NS fmt
82 #elif QX_CONF_FMT_LIB == QX_FMT_LIB_STD
83  #include <format>
84  #define QX_FMT_NS std
85 #else
86  #error No fmt lib selected
87 #endif
Contains utils for working with std::tuple.