MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_system_locale.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_SYSTEM_LOCALE_H_1614100027
12#define INCGUARD_MGL_SYSTEM_LOCALE_H_1614100027
13
14#include <mgl/event/mgl_event.h>
15#include <mgl/mgl_environment.h>
18
19namespace MGL::System
20{
22class Locale
23{
24public:
25 /* ------------------------------------------------------------------------- */
29 /* ------------------------------------------------------------------------- */
30 Locale() noexcept
31 : _locale(ModuleSet::GetInstance().GetLocaleModule())
32 {}
33
34 /* ------------------------------------------------------------------------- */
39 /* ------------------------------------------------------------------------- */
40 [[nodiscard]] Language GetLanguage() const noexcept
41 {
42 return _locale.GetLocaleInfo().language;
43 }
44
45 /* ------------------------------------------------------------------------- */
50 /* ------------------------------------------------------------------------- */
51 [[nodiscard]] Language GetDefaultLanguage() const noexcept
52 {
53 return _locale.GetDefaultLocaleInfo().language;
54 }
55
56 /* ------------------------------------------------------------------------- */
61 /* ------------------------------------------------------------------------- */
62 void SetLanguage(Language language) noexcept
63 {
64 auto &currentLocaleInfo = _locale.GetLocaleInfo();
65 if (currentLocaleInfo.language != language)
66 {
67 currentLocaleInfo.language = language;
68 Event::Notify(Event::NotifyType::ChangeLanguage, &currentLocaleInfo.language);
69 }
70 }
71
72 /* ------------------------------------------------------------------------- */
77 /* ------------------------------------------------------------------------- */
78 [[nodiscard]] int32_t GetTimeDifference() const noexcept
79 {
80 return _locale.GetLocaleInfo().timeDifference;
81 }
82
83 /* ------------------------------------------------------------------------- */
88 /* ------------------------------------------------------------------------- */
89 [[nodiscard]] int32_t GetDefaultTimeDifference() const noexcept
90 {
91 return _locale.GetDefaultLocaleInfo().timeDifference;
92 }
93
94 /* ------------------------------------------------------------------------- */
99 /* ------------------------------------------------------------------------- */
100 void SetTimeDifference(int32_t timeDifference) noexcept
101 {
102 _locale.GetLocaleInfo().timeDifference = timeDifference;
103 }
104
105 /* ------------------------------------------------------------------------- */
110 /* ------------------------------------------------------------------------- */
112 {
114 }
115
116 /* ------------------------------------------------------------------------- */
121 /* ------------------------------------------------------------------------- */
122 [[nodiscard]] uint8_t GetGroupingSize() const noexcept
123 {
124 return _locale.GetLocaleInfo().groupingSize;
125 }
126
127 /* ------------------------------------------------------------------------- */
132 /* ------------------------------------------------------------------------- */
133 [[nodiscard]] uint8_t GetDefaultGroupingSize() const noexcept
134 {
135 return _locale.GetDefaultLocaleInfo().groupingSize;
136 }
137
138 /* ------------------------------------------------------------------------- */
143 /* ------------------------------------------------------------------------- */
144 void SetGroupingSize(uint8_t groupingSize) noexcept
145 {
146 _locale.GetLocaleInfo().groupingSize = groupingSize;
147 }
148
149 /* ------------------------------------------------------------------------- */
154 /* ------------------------------------------------------------------------- */
155 [[nodiscard]] const char *GetGroupingSeparator() const noexcept
156 {
157 return _locale.GetLocaleInfo().groupingSeparator.c_str();
158 }
159
160 /* ------------------------------------------------------------------------- */
165 /* ------------------------------------------------------------------------- */
166 [[nodiscard]] const char *GetDefaultGroupingSeparator() const noexcept
167 {
168 return _locale.GetDefaultLocaleInfo().groupingSeparator.c_str();
169 }
170
171 /* ------------------------------------------------------------------------- */
176 /* ------------------------------------------------------------------------- */
177 void SetGroupingSeparator(const char *separator) noexcept
178 {
179 _locale.GetLocaleInfo().groupingSeparator = separator;
180 }
181
182 /* ------------------------------------------------------------------------- */
187 /* ------------------------------------------------------------------------- */
188 [[nodiscard]] const char *GetDecimalSeparator() const noexcept
189 {
190 return _locale.GetLocaleInfo().decimalSeparator.c_str();
191 }
192
193 /* ------------------------------------------------------------------------- */
198 /* ------------------------------------------------------------------------- */
199 [[nodiscard]] const char *GetDefaultDecimalSeparator() const noexcept
200 {
201 return _locale.GetDefaultLocaleInfo().decimalSeparator.c_str();
202 }
203
204 /* ------------------------------------------------------------------------- */
209 /* ------------------------------------------------------------------------- */
210 void SetDecimalSeparator(const char *separator) noexcept
211 {
212 _locale.GetLocaleInfo().decimalSeparator = separator;
213 }
214
215private:
216 LocaleModuleInterface &_locale;
217};
218} // namespace MGL::System
219
220#endif // INCGUARD_MGL_SYSTEM_LOCALE_H_1614100027
221
222// vim: et ts=4 sw=4 sts=4
日付と時間のクラス
Definition mgl_system_chrono.h:21
EpochTime GetCurrentEpochTime() const noexcept
現在時刻をエポック時間で取得
Definition mgl_system_chrono.h:38
ロケール情報クラス
Definition mgl_system_locale.h:23
const char * GetGroupingSeparator() const noexcept
数値の桁区切り記号を取得
Definition mgl_system_locale.h:155
void SetTimeDifference(int32_t timeDifference) noexcept
時差を設定
Definition mgl_system_locale.h:100
Locale() noexcept
コンストラクタ
Definition mgl_system_locale.h:30
DateTime GetLocalDateTime() noexcept
現在のローカル時刻を取得
Definition mgl_system_locale.h:111
const char * GetDecimalSeparator() const noexcept
小数点の区切り記号を取得
Definition mgl_system_locale.h:188
const char * GetDefaultDecimalSeparator() const noexcept
デフォルトの小数点の区切り記号を取得
Definition mgl_system_locale.h:199
void SetGroupingSeparator(const char *separator) noexcept
数値の桁区切り記号を設定
Definition mgl_system_locale.h:177
int32_t GetDefaultTimeDifference() const noexcept
デフォルトの時差を取得
Definition mgl_system_locale.h:89
const char * GetDefaultGroupingSeparator() const noexcept
デフォルトの数値の桁区切り記号を取得
Definition mgl_system_locale.h:166
void SetDecimalSeparator(const char *separator) noexcept
小数点の区切り記号を設定
Definition mgl_system_locale.h:210
int32_t GetTimeDifference() const noexcept
時差を取得
Definition mgl_system_locale.h:78
Language GetDefaultLanguage() const noexcept
デフォルトの言語を取得
Definition mgl_system_locale.h:51
Language GetLanguage() const noexcept
言語を取得
Definition mgl_system_locale.h:40
uint8_t GetGroupingSize() const noexcept
桁区切りの間隔を取得
Definition mgl_system_locale.h:122
void SetGroupingSize(uint8_t groupingSize) noexcept
桁区切りの間隔を設定
Definition mgl_system_locale.h:144
void SetLanguage(Language language) noexcept
言語を設定
Definition mgl_system_locale.h:62
uint8_t GetDefaultGroupingSize() const noexcept
デフォルトの桁区切りの間隔を取得
Definition mgl_system_locale.h:133
ローケール情報モジュールのインターフェース
Definition mgl_locale_module_interface.h:20
virtual const LocaleInfo & GetDefaultLocaleInfo() const noexcept=0
デフォルトのロケール情報を取得
virtual LocaleInfo & GetLocaleInfo() noexcept=0
ロケール情報を取得
システム関連モジュールセットクラス
Definition mgl_system_module_set.h:27
MGL 環境定義
MGL イベント
Language
言語
Definition mgl_locale_info.h:22
MGL 日付と時間
MGL システム関連モジュールセット
日付と時刻
Definition mgl_chrono_defs.h:27
uint8_t groupingSize
区切り桁数
Definition mgl_locale_info.h:62
int32_t timeDifference
UTC基準の時差
Definition mgl_locale_info.h:61
Language language
言語
Definition mgl_locale_info.h:60
STL::string decimalSeparator
小数点記号
Definition mgl_locale_info.h:64
STL::string groupingSeparator
桁区切り記号
Definition mgl_locale_info.h:63