OpenTTD Source: src/string_type.h Source File

OpenTTD Source 13.1

string_type.h
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10 #ifndef STRING_TYPE_H
11 #define STRING_TYPE_H
12
13 #include "core/enum_type.hpp"
14 #include <vector>
15 #include <string>
16
18 #define NBSP u8"\u00a0"
19
21 #define LRM u8"\u200e"
22
26 enum CharSetFilter {
27 CS_ALPHANUMERAL,
28 CS_NUMERAL,
29 CS_NUMERAL_SPACE,
30 CS_NUMERAL_SIGNED,
31 CS_ALPHA,
32 CS_HEXADECIMAL,
33 };
34
36 typedef char32_t WChar;
37
38 /* The following are directional formatting codes used to get the LTR and RTL strings right:
39 * http://www.unicode.org/unicode/reports/tr9/#Directional_Formatting_Codes */
40 static const WChar CHAR_TD_LRM = 0x200E;
41 static const WChar CHAR_TD_RLM = 0x200F;
42 static const WChar CHAR_TD_LRE = 0x202A;
43 static const WChar CHAR_TD_RLE = 0x202B;
44 static const WChar CHAR_TD_LRO = 0x202D;
45 static const WChar CHAR_TD_RLO = 0x202E;
46 static const WChar CHAR_TD_PDF = 0x202C;
47
49 enum StringValidationSettings {
50 SVS_NONE = 0,
51 SVS_REPLACE_WITH_QUESTION_MARK = 1 << 0,
52 SVS_ALLOW_NEWLINE = 1 << 1,
53 SVS_ALLOW_CONTROL_CODE = 1 << 2,
54 };
55 DECLARE_ENUM_AS_BIT_SET(StringValidationSettings)
56
57
58
59 typedef std::vector<std::string> StringList;
60
61 #endif /* STRING_TYPE_H */
WChar
char32_t WChar
Type for wide characters, i.e.
Definition: string_type.h:36
SVS_ALLOW_NEWLINE
@ SVS_ALLOW_NEWLINE
Allow newlines.
Definition: string_type.h:52
CHAR_TD_LRO
static const WChar CHAR_TD_LRO
Force the following characters to be treated as left-to-right characters.
Definition: string_type.h:44
CS_ALPHA
@ CS_ALPHA
Only alphabetic values.
Definition: string_type.h:31
CHAR_TD_RLO
static const WChar CHAR_TD_RLO
Force the following characters to be treated as right-to-left characters.
Definition: string_type.h:45
CHAR_TD_RLE
static const WChar CHAR_TD_RLE
The following text is embedded right-to-left.
Definition: string_type.h:43
SVS_ALLOW_CONTROL_CODE
@ SVS_ALLOW_CONTROL_CODE
Allow the special control codes.
Definition: string_type.h:53
CHAR_TD_PDF
static const WChar CHAR_TD_PDF
Restore the text-direction state to before the last LRE, RLE, LRO or RLO.
Definition: string_type.h:46
CHAR_TD_LRE
static const WChar CHAR_TD_LRE
The following text is embedded left-to-right.
Definition: string_type.h:42
StringList
std::vector< std::string > StringList
Type for a list of strings.
Definition: string_type.h:59
CHAR_TD_RLM
static const WChar CHAR_TD_RLM
The next character acts like a right-to-left character.
Definition: string_type.h:41
CS_ALPHANUMERAL
@ CS_ALPHANUMERAL
Both numeric and alphabetic and spaces and stuff.
Definition: string_type.h:27
StringValidationSettings
StringValidationSettings
Settings for the string validation.
Definition: string_type.h:49
enum_type.hpp
CS_NUMERAL_SIGNED
@ CS_NUMERAL_SIGNED
Only numbers and '-' for negative values.
Definition: string_type.h:30
SVS_NONE
@ SVS_NONE
Allow nothing and replace nothing.
Definition: string_type.h:50
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:29
CHAR_TD_LRM
static const WChar CHAR_TD_LRM
The next character acts like a left-to-right character.
Definition: string_type.h:40
CS_NUMERAL_SPACE
@ CS_NUMERAL_SPACE
Only numbers and spaces.
Definition: string_type.h:29
CS_HEXADECIMAL
@ CS_HEXADECIMAL
Only hexadecimal characters.
Definition: string_type.h:32
SVS_REPLACE_WITH_QUESTION_MARK
@ SVS_REPLACE_WITH_QUESTION_MARK
Replace the unknown/bad bits with question marks.
Definition: string_type.h:51
CS_NUMERAL
@ CS_NUMERAL
Only numeric ones.
Definition: string_type.h:28
CharSetFilter
CharSetFilter
Valid filter types for IsValidChar.
Definition: string_type.h:26