YSTest: Initialization.cpp 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

Initialization.cpp
浏览该文件的文档.
1 /*
2 © 2009-2016 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #include "Helper/YModules.h"
29 #include YFM_Helper_Initialization
30 #include YFM_YCLib_MemoryMapping // for MappedFile;
31 #include YFM_YSLib_Core_YException // for ExtractException;
32 #include YFM_CHRLib_MappingEx // for CHRLib::cp113_lkp;
33 #include YFM_YSLib_Service_TextFile // for Text::BOM_UTF_8, Text::CheckBOM;
34 #include YFM_NPL_Configuration // for NPL::Configuration;
35 #include YFM_Helper_Environment // for Environment::AddExitGuard;
36 #include <ystdex/string.hpp> // for ystdex::write_literal, ystdex::sfmt;
37 #include <cerrno> // for errno;
38 #include YFM_YSLib_Service_FileSystem // for IO::TraverseChildren;
39 #include YFM_Helper_GUIApplication // for FetchEnvironment;
40 //#include <clocale>
41 #if YCL_Win32
42 # include YFM_Win32_YCLib_NLS // for platform_ex::FetchDBCSOffset;
43 #endif
44 #include YFM_NPL_SContext
45
46 using namespace ystdex;
47 using namespace platform;
49 using namespace NPL;
50
51 namespace YSLib
52 {
53
54 using namespace Drawing;
55 using namespace IO;
56
57 #if YCL_DS
58 bool ShowInitializedLog(true);
59 #endif
60
61 namespace
62 {
63
65 unique_ptr<ValueNode> p_root;
67 yconstexpr const char TU_MIME[]{u8R"NPLA1(
68 (application
69 (octet-stream "bin" "so")
70 (x-msdownload "exe" "dll" "com" "bat" "msi")
71 (x-font-ttf "ttf" "ttc")
72 (xml "xml")
73 (zip "zip")
74 )
75 (audio
76 (midi "mid" "midi" "rmi")
77 (mpeg "mp3")
78 (x-mpegurl "m3u")
79 (x-wav "wav")
80 )
81 (image
82 (bmp "bmp")
83 (gif "gif")
84 (jpeg "jpeg" "jpg")
85 (png "png")
86 (tif "tif" "tiff")
87 )
88 (text
89 (html "html" "htm")
90 (plain "txt" "conf" "def" "ini" "log" "in")
91 (x-c "c" "h" "inl")
92 (x-c++ "cc" "cpp" "cxx" "h" "hh" "hpp" "hxx" "inl")
93 )
94 )NPLA1"};
95
96 #undef CONF_PATH
97 #undef DATA_DIRECTORY
98 #undef DEF_FONT_DIRECTORY
99 #undef DEF_FONT_PATH
100 #if YCL_Win32 || YCL_Android
101 const string&
103 FetchWorkingRoot()
104 {
105 static const struct Init
106 {
107 string Path;
108
109 Init()
110 : Path([]{
111 # if YCL_Win32
112 IO::Path image(platform::ucast(
113 platform_ex::FetchModuleFileName().data()));
114
115 if(!image.empty())
116 image.pop_back();
117 auto res(image.GetString().GetMBCS());
118
119 if(Verify(res))
120 return res;
121 # else
122 const char*
123 sd_paths[]{"/sdcard/", "/mnt/sdcard/", "/storage/sdcard0/"};
124
125 for(const auto& path : sd_paths)
126 if(Verify(path))
127 {
128 YTraceDe(Informative, "Successfully found SD card path"
129 " '%s' as root path.", path);
130 return path;
131 }
132 else
133 YTraceDe(Informative,
134 "Failed accessing SD card path '%s'.", path);
135 # endif
136 throw GeneralEvent("Failed finding working root path.");
137 }())
138 {}
139
140 static bool
141 Verify(const string& path)
142 {
143 if(IO::VerifyDirectory(path))
144 {
145 YTraceDe(Informative, "Initialized image path '%s'.",
146 path.c_str());
147 return true;
148 }
149 return {};
150 }
151 } init;
152
153 return init.Path;
154 }
155
156 // TODO: Reduce overhead?
157 # define CONF_PATH (FetchWorkingRoot() + "yconf.txt").c_str()
158 #endif
159 #if YCL_DS
160 # define DATA_DIRECTORY "/Data/"
161 # define DEF_FONT_DIRECTORY "/Font/"
162 # define DEF_FONT_PATH "/Font/FZYTK.TTF"
163 #elif YCL_Win32
164 # define DATA_DIRECTORY FetchWorkingRoot()
165 # define DEF_FONT_PATH (FetchSystemFontDirectory_Win32() + "SimSun.ttc")
166 inline PDefH(string, FetchSystemFontDirectory_Win32, )
168 // NOTE: Hard-coded as Shell32 special path with %CSIDL_FONTS or
169 // %CSIDL_FONTS. See https://msdn.microsoft.com/en-us/library/dd378457.aspx.
170 ImplRet(platform_ex::WCSToMBCS(platform_ex::FetchWindowsPath()) + "Fonts\\")
171 #elif YCL_Android
172 # define DATA_DIRECTORY (FetchWorkingRoot() + "Data/")
173 # define DEF_FONT_DIRECTORY "/system/fonts/"
174 # define DEF_FONT_PATH "/system/fonts/DroidSansFallback.ttf"
175 #elif YCL_Linux
176 # define DEF_FONT_PATH "./SimSun.ttc"
177 #else
178 # error "Unsupported platform found."
179 #endif
180 #ifndef CONF_PATH
181 # define CONF_PATH "yconf.txt"
182 #endif
183 #ifndef DATA_DIRECTORY
184 # define DATA_DIRECTORY "./"
185 #endif
186 #ifndef DEF_FONT_DIRECTORY
187 # define DEF_FONT_DIRECTORY DATA_DIRECTORY
188 #endif
189
191 unique_ptr<MappedFile>
192 LoadMappedModule(const string& path)
193 {
194 TryRet(make_unique<MappedFile>(path))
195 CatchExpr(..., std::throw_with_nested(
196 GeneralEvent("Loading module '" + path + "' failed.")))
197 YAssert(false, "Unreachable control found.");
198 }
199
200 #if YCL_Win32
201 char16_t(*cp113_lkp_backup)(byte, byte);
204
205 const unsigned short* p_dbcs_off_936;
206
207 void
208 LoadCP936_NLS()
209 {
210 using namespace platform_ex;
211
212 if((p_dbcs_off_936 = FetchDBCSOffset(936)))
213 {
214 cp113_lkp_backup = CHRLib::cp113_lkp;
215 CHRLib::cp113_lkp = [](byte seq0, byte seq1) ynothrowv -> char16_t{
216 return p_dbcs_off_936[p_dbcs_off_936[seq0] + seq1];
217 };
218 }
219 }
221 #endif
222
224 void
225 CreateDefaultNPLA1ForStream(std::ostream& os, ValueNode(*creator)())
226 {
227 ystdex::write_literal(os, Text::BOM_UTF_8)
228 << NPL::Configuration(creator());
229 }
230
231 ValueNode
232 TryReadNPLStream(std::istream& is)
233 {
234 array<char, 3> buf;
235
236 is.read(buf.data(), 3);
237 if(Text::CheckBOM(buf.data(), Text::BOM_UTF_8))
238 {
239 NPL::Configuration conf;
240
241 is >> conf;
242 YTraceDe(Debug, "Plain configuration loaded.");
243 if(!conf.GetNodeRRef().empty())
244 return conf.GetNodeRRef();
245 YTraceDe(Warning, "Empty configuration found.");
246 throw GeneralEvent("Invalid file found when reading configuration.");
247 }
248 else
249 throw GeneralEvent("Wrong encoding of configuration file.");
250 }
251
252 YB_NONNULL(1, 2) bool
253 CreateDefaultNPLA1File(const char* disp, const char* path,
254 ValueNode(*creator)(), bool show_info)
255 {
256 YAssertNonnull(disp),
257 YAssertNonnull(path);
258 if(show_info)
259 YTraceDe(Notice, "Creating %s '%s'...\n", disp, path);
260 if(creator)
261 {
262 YTraceDe(Debug, "Creator found.");
263 if(ofstream ofs{path, std::ios_base::out | std::ios_base::trunc})
264 CreateDefaultNPLA1ForStream(ofs, creator);
265 else
266 throw GeneralEvent(ystdex::sfmt("Cannot create file,"
267 " error = %d: %s.", errno, std::strerror(errno)));
268 YTraceDe(Debug, "Created configuration.");
269 return {};
270 }
271 return true;
272 }
273
274 } // unnamed namespace;
275
276 void
277 ExtractInitException(const std::exception& e, string& res) ynothrow
278 {
279 ExtractException(
280 [&](const string& str, RecordLevel, size_t level){
281 res += string(level, ' ') + "ERROR: " + str + '\n';
282 }, e);
283 }
284
285 void
286 TraceForOutermost(const std::exception& e, RecordLevel lv) ynothrow
287 {
288 #if YCL_DS
289 ShowInitializedLog = {};
290 #endif
291 if(const auto p = dynamic_cast<const YSLib::FatalError*>(&e))
292 {
293 #if YCL_Win32
294 using platform_ex::MBCSToWCS;
295
296 FilterExceptions([&]{
297 ::MessageBoxW({}, MBCSToWCS(p->GetContent()).c_str(),
298 MBCSToWCS(p->GetTitle()).data(), MB_ICONERROR);
299 });
300 #endif
301 YTraceDe(Emergent, "%s\n\n%s", p->GetTitle(), p->GetContent().data());
302 terminate();
303 }
304 else
305 ExtractAndTrace(e, lv);
306 }
307
308 ValueNode
309 LoadNPLA1File(const char* disp, const char* path, ValueNode(*creator)(),
310 bool show_info)
311 {
312 if(!ufexists(path))
313 {
314 YTraceDe(Debug, "Path '%s' access failed.", path);
315 if(CreateDefaultNPLA1File(disp, path, creator, show_info))
316 return {};
317 }
318 if(show_info)
319 YTraceDe(Notice, "Found %s '%s'.\n", Nonnull(disp), path);
320
321 auto res(TryInvoke([&]() -> ValueNode{
322 if(ifstream ifs{path})
323 {
324 YTraceDe(Debug, "Found accessible configuration file.");
325 return TryReadNPLStream(ifs);
326 }
327 return {};
328 }));
329
330 if(res)
331 return res;
332
333 YTraceDe(Warning, "Newly created configuration corrupted,"
334 " trying fallback in memory...");
335
336 std::stringstream oss;
337
338 CreateDefaultNPLA1ForStream(oss, creator);
339 return TryReadNPLStream(oss);
340 }
341
342 void
343 LoadComponents(Application& app, const ValueNode& node)
344 {
345 const auto& data_dir(AccessChild<string>(node, "DataDirectory"));
346 const auto& font_path(AccessChild<string>(node, "FontFile"));
347 const auto& font_dir(AccessChild<string>(node, "FontDirectory"));
348
349 if(!data_dir.empty() && !font_path.empty() && !font_dir.empty())
350 YTraceDe(Notice, "Loaded default directory:\n%s\n"
351 "Loaded default font path:\n%s\n"
352 "Loaded default font directory:\n%s\n",
353 data_dir.c_str(), font_path.c_str(), font_dir.c_str());
354 else
355 throw GeneralEvent("Empty path loaded.");
356 #if !CHRLib_NoDynamicMapping
357
358 static unique_ptr<MappedFile> p_mapped;
359 const string mapping_name(data_dir + "cp113.bin");
360
361 YTraceDe(Notice, "Loading character mapping file '%s' ...\n",
362 mapping_name.c_str());
363 try
364 {
365 p_mapped = LoadMappedModule(data_dir + "cp113.bin");
366 if(p_mapped->GetSize() != 0)
367 CHRLib::cp113 = p_mapped->GetPtr();
368 else
369 throw GeneralEvent("Failed loading CHRMapEx.");
370 YTraceDe(Notice, "CHRMapEx loaded successfully.");
371 }
372 catch(std::exception& e)
373 {
374 YTraceDe(Notice, "Module cp113.bin loading failed, error: %s",
375 e.what());
376 # if YCL_Win32
377 LoadCP936_NLS();
378 if(p_dbcs_off_936)
379 YTraceDe(Notice, "NLS CP936 used as fallback.");
380 else
381 # endif
382 {
383 CHRLib::cp113_lkp = [](byte, byte) YB_ATTR(noreturn) -> char16_t{
384 throw LoggedEvent("Failed calling conversion for CHRMapEx.");
385 };
386 YTraceDe(Warning, "CHRMapEx conversion calls would lead to"
387 " exception thrown.");
388 }
389 }
390 app.AddExitGuard([]() ynothrow{
391 # if YCL_Win32
392 if(cp113_lkp_backup)
393 {
394 CHRLib::cp113_lkp = cp113_lkp_backup;
395 cp113_lkp_backup = {};
396 }
397 # endif
398 p_mapped.reset();
399 YTraceDe(Notice, "Character mapping deleted.");
400 });
401 #endif
402 YTraceDe(Notice, "Trying entering directory '%s' ...\n",
403 data_dir.c_str());
404 if(!IO::VerifyDirectory(data_dir))
405 throw GeneralEvent("Invalid default data directory found.");
406 if(!(ufexists(font_path.c_str()) || IO::VerifyDirectory(font_dir)))
407 throw GeneralEvent("Invalid default font file path found.");
408 }
409
410 ValueNode
411 LoadConfiguration(bool show_info)
412 {
413 return LoadNPLA1File("configuration file", CONF_PATH, []{
414 return ValueNode(NodeLiteral{"YFramework",
415 {{"DataDirectory", DATA_DIRECTORY}, {"FontFile", DEF_FONT_PATH},
416 {"FontDirectory", DEF_FONT_DIRECTORY}}});
417 }, show_info);
418 }
419
420 void
421 SaveConfiguration(const ValueNode& node)
422 {
423 if(ofstream ofs{CONF_PATH, std::ios_base::out | std::ios_base::trunc})
424 {
425 YTraceDe(Debug, "Writing configuration...");
426 ystdex::write_literal(ofs, Text::BOM_UTF_8)
427 << NPL::Configuration(ValueNode(node.GetContainer()));
428 }
429 else
430 throw GeneralEvent("Invalid file found when writing configuration.");
431 YTraceDe(Debug, "Writing configuration done.");
432 }
433
434
435 void
436 InitializeSystemFontCache(FontCache& fc, const string& font_file,
437 const string& font_dir)
438 {
439 string res;
440
441 YTraceDe(Notice, "Loading font files...");
442 try
443 {
444 size_t loaded(fc.LoadTypefaces(font_file) != 0 ? 1 : 0);
445
446 if(!font_dir.empty())
447 try
448 {
449 IO::TraverseChildren(font_dir,
450 [&](NodeCategory c, NativePathView npv){
451 if(!bool(c & NodeCategory::Directory))
452 {
453 const FontPath path(font_dir + String(npv).GetMBCS());
454
455 if(path != font_file && fc.LoadTypefaces(path) != 0)
456 ++loaded;
457 }
458 });
459 }
460 CatchIgnore(FileOperationFailure&)
461 fc.InitializeDefaultTypeface();
462
463 const auto faces(fc.GetFaces().size());
464
465 if(faces != 0)
466 YTraceDe(Notice, "%zu face(s) in %zu font file(s)"
467 " are loaded\nsuccessfully.\n", faces, loaded);
468 else
469 throw GeneralEvent("No fonts found.");
470 YTraceDe(Notice, "Setting default font face...");
471 if(const auto pf = fc.GetDefaultTypefacePtr())
472 YTraceDe(Notice, "\"%s\":\"%s\",\nsuccessfully.\n",
473 pf->GetFamilyName().c_str(), pf->GetStyleName().c_str());
474 else
475 throw GeneralEvent("Setting default font face failed.");
476 return;
477 }
478 CatchExpr(std::exception& e, ExtractInitException(e, res))
479 CatchExpr(..., res += "Unknown exception @ InitializeSystemFontCache.\n")
480 throw FatalError(" Font Caching Failure ",
481 " Please make sure the fonts are\n"
482 " stored in correct path.\n" + res);
483 }
484
485
486 ValueNode&
487 FetchRoot() ynothrow
488 {
489 return FetchEnvironment().Root;
490 }
491
492 Drawing::FontCache&
493 FetchDefaultFontCache()
494 {
495 static unique_ptr<Drawing::FontCache> p_font_cache;
496
497 if(YB_UNLIKELY(!p_font_cache))
498 {
499 p_font_cache.reset(new Drawing::FontCache());
500 FetchAppInstance().AddExitGuard([&]() ynothrow{
501 p_font_cache.reset();
502 });
503
504 const auto& node(FetchEnvironment().Root["YFramework"]);
505
506 InitializeSystemFontCache(*p_font_cache,
507 AccessChild<string>(node, "FontFile"),
508 AccessChild<string>(node, "FontDirectory"));
509 }
510 #if YCL_DS
511 // XXX: Actually this should be set after %InitVideo call.
512 ShowInitializedLog = {};
513 #endif
514 return *p_font_cache;
515 }
516
517 MIMEBiMapping&
518 FetchMIMEBiMapping()
519 {
520 static unique_ptr<MIMEBiMapping> p_mapping;
521
522 if(YB_UNLIKELY(!p_mapping))
523 {
524 using namespace NPL;
525
526 p_mapping.reset(new MIMEBiMapping());
527 AddMIMEItems(*p_mapping, LoadNPLA1File("MIME database",
528 (AccessChild<string>(FetchEnvironment().Root["YFramework"], "DataDirectory")
529 + "MIMEExtMap.txt").c_str(), []{
530 return A1::LoadNode(SContext::Analyze(NPL::Session(TU_MIME)));
531 }, true));
532 FetchAppInstance().AddExitGuard([&]() ynothrow{
533 p_mapping.reset();
534 });
535 }
536 return *p_mapping;
537 }
538
539 } // namespace YSLib;
540
YSLib::UI::fc
fc
Definition: Console.h:93
CHRLib::cp113_lkp
char16_t(* cp113_lkp)(byte, byte)
查找编码转换序列的实现。
Definition: MappingEx.cpp:64
platform::p
while p p
Definition: YCLib/FileSystem.h:225
YSLib::lv
RecordLevel lv
Definition: YException.cpp:58
YSLib::Application::AddExitGuard
void AddExitGuard(_func f)
Definition: YApplication.h:110
ystdex::sfmt
auto sfmt(const _tChar *fmt,...) -> decltype(vsfmt(fmt, std::declval< std::va_list >()))
以 C 标准输出格式的输出 std::basic_string 实例的对象。
Definition: string.hpp:1140
YSLib::FatalError
致命错误。
Definition: YException.h:89
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:653
CONF_PATH
#define CONF_PATH
Definition: Initialization.cpp:181
YSLib::Drawing::FontPath
string FontPath
字体文件路径。
Definition: Font.h:78
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:740
platform::containers::string
basic_string< char > string
Definition: Container.h:101
platform::Nonnull
_type && Nonnull(_type &&p) ynothrow
断言并返回非空指针。
Definition: Debug.h:411
platform::Descriptions::Warning
Definition: YCommon.h:157
platform::Descriptions::Informative
Definition: YCommon.h:159
YSLib::Text::buf
const char * buf
Definition: TextFile.h:77
YSLib::FetchDefaultFontCache
YF_API Drawing::FontCache & FetchDefaultFontCache()
取默认字体缓存。 字体缓存初始化失败。
Definition: Initialization.cpp:493
YSLib::GeneralEvent
std::runtime_error GeneralEvent
一般运行时异常事件类。
Definition: YException.h:45
YSLib::Drawing::FontCache
字体缓存。
Definition: Font.h:460
DATA_DIRECTORY
#define DATA_DIRECTORY
Definition: Initialization.cpp:184
YSLib::Text::BOM_UTF_8
yconstexpr const char BOM_UTF_8[]
Definition: TextFile.h:66
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
YSLib::FetchMIMEBiMapping
YF_API MIMEBiMapping & FetchMIMEBiMapping()
取 MIME 类型名和文件扩展名双向映射对象。
Definition: Initialization.cpp:518
CHRLib::e
const char const char * e
Definition: CharacterProcessing.h:109
platform::NodeCategory
NodeCategory
文件节点类别。
Definition: FileIO.h:117
ynothrowv
#define ynothrowv
YSLib 无异常抛出保证验证：有条件地使用无异常抛出规范。
Definition: ydef.h:760
YSLib::FilterExceptions
bool FilterExceptions(_func f, const char *desc={}, RecordLevel lv=Alert, ExceptionTracer trace=ExtractAndTrace) ynothrow
调用函数并过滤宿主异常。
Definition: YException.h:202
CatchExpr
#define CatchExpr(_ex,...)
指定表达式作为异常处理器。
Definition: YBaseMacro.h:129
YAssert
#define YAssert(_expr, _msg)
Definition: cassert.h:105
YSLib::creator
YF_API const char ValueNode(* creator)()
Definition: Initialization.h:75
platform_ex::Windows::FetchWindowsPath
YF_API wstring FetchWindowsPath(size_t=MAX_PATH)
取系统目录路径。
YSLib::LoggedEvent
记录日志的异常事件类。
Definition: YException.h:49
ystdex::data
auto data(_tRange &c) -> decltype(c.data())
Definition: range.hpp:280
platform_ex::Windows::Directory
Definition: MinGW32.h:442
YSLib::Text::String
YSLib 标准字符串（使用 UCS-2 作为内部编码）。
Definition: YString.h:46
CHRLib::c
c
Definition: CharacterProcessing.h:81
YSLib::IO::VerifyDirectory
VerifyDirectory
Definition: YSLib/Service/FileSystem.h:394
platform::Descriptions::Emergent
Definition: YCommon.h:153
platform::ufexists
bool ufexists(const char *filename) ynothrowv
Definition: FileIO.cpp:875
YSLib::NodeLiteral
包装节点的组合字面量。
Definition: ValueNode.h:895
CHRLib::char16_t
char16_t((*c_ptr<< CHAR_BIT)|c_ptr[1])) inline PDefH(char16_t
取 c_ptr 指向的小端序双字节字符。
YTraceDe
#define YTraceDe(...)
YCLib 默认调试跟踪。
Definition: Debug.h:305
YSLib::Drawing::FontCache::GetDefaultTypefacePtr
observer_ptr< const Typeface > GetDefaultTypefacePtr() const
取默认字型指针。 异常中立：初始化时发生的异常。
Definition: Font.cpp:418
CatchIgnore
#define CatchIgnore(_ex)
指定异常处理器忽略指定异常。
Definition: YBaseMacro.h:133
YSLib::TryInvoke
ystdex::result_of_t< _fCallable &&(_tParams &&...)> TryInvoke(_fCallable &&f, _tParams &&...args) ynothrow
调用函数并试图返回。
Definition: YException.h:185
YSLib::Drawing::FontCache::LoadTypefaces
size_t LoadTypefaces(const FontPath &)
从字体文件组中载入字型信息。
Definition: Font.cpp:443
YSLib::Application
程序实例。
Definition: YApplication.h:46
ystdex::path_category::node
YB_UNLIKELY
#define YB_UNLIKELY(_expr)
分支预测提示。
Definition: ydef.h:438
YSLib::Drawing::FontCache::InitializeDefaultTypeface
void InitializeDefaultTypeface()
初始化默认字型。
Definition: Font.cpp:487
YSLib::show_info
YF_API const char ValueNode(*) boo show_info)
Definition: Initialization.h:75
platform
默认平台命名空间。
Definition: Container.h:47
YAssertNonnull
#define YAssertNonnull(_expr)
Definition: cassert.h:114
YB_ATTR
#define YB_ATTR(...)
GNU 风格属性。
Definition: ydef.h:347
ystdex::basic_string_view
Definition: string_view.hpp:49
platform_ex
平台扩展命名空间。
Definition: Android.h:45
YSLib::path
YF_API const char * path
Definition: Initialization.h:74
ystdex::path
一般路径模板。
Definition: path.hpp:123
IO
platform_ex::Windows::FetchModuleFileName
YF_API wstring FetchModuleFileName(::HMODULE={})
取模块映像路径。
ystdex
特性测试宏。
Definition: ydef.h:796
YSLib::Text::str
const char const char * str
Definition: TextFile.h:77
YSLib::SaveConfiguration
YF_API void SaveConfiguration(const ValueNode &)
保存默认配置。
Definition: Initialization.cpp:421
YSLib::LoadComponents
YF_API void LoadComponents(Application &, const ValueNode &)
初始化应用程序组件。
Definition: Initialization.cpp:343
NPL
Definition: NPL/Configuration.h:34
NPL::Configuration
设置：使用 S 表达式存储外部状态。
Definition: NPL/Configuration.h:42
YSLib::IO::TraverseChildren
void TraverseChildren(const string &path, _func f)
Definition: YSLib/Service/FileSystem.h:485
platform::FileOperationFailure
表示文件操作失败的异常。
Definition: FileIO.h:1142
platform_ex::Windows::WCSToMBCS
YF_API string WCSToMBCS(wstring_view, unsigned=CP_ACP)
NPL::SContext::Analyze
YF_API void Analyze(TermNode &, const TokenList &)
分析指定源，取抽象语法树储存至指定值类型节点。
Definition: SContext.cpp:92
DEF_FONT_DIRECTORY
#define DEF_FONT_DIRECTORY
Definition: Initialization.cpp:187
TryRet
#define TryRet(...)
指定表达式在 try 块中求值并返回。
Definition: YBaseMacro.h:124
Drawing
NPL::A1::LoadNode
ValueNode LoadNode(_type &&tree, _tParams &&...args)
加载 NPLA1 翻译单元。
Definition: NPLA1.h:126
YSLib::MIMEBiMapping
MIME 和文件扩展名双向映射。
Definition: ContentType.h:44
YSLib::FetchRoot
YF_API ValueNode & FetchRoot() ynothrow
取值类型根节点。
Definition: Initialization.cpp:487
YSLib::Text::CheckBOM
CheckBOM
Definition: TextFile.h:77
platform_ex::Windows::MBCSToWCS
YF_API wstring MBCSToWCS(string_view, unsigned=CP_ACP)
ystdex::byte
unsigned char byte
字节类型。
Definition: ydef.h:808
YSLib::AddMIMEItems
YF_API void AddMIMEItems(MIMEBiMapping &, const ValueNode &, MIMEBiMapping::MIMEType &&={})
根据 NPLA1 节点内容增加 MIME 映射。
Definition: ContentType.cpp:62
ystdex::write_literal
std::basic_ostream< _tChar, _tTraits > & write_literal(std::basic_ostream< _tChar, _tTraits > &os, const _tChar(&s)[_vN])
Definition: string.hpp:945
platform::Descriptions::Debug
Definition: YCommon.h:160
string.hpp
ISO C++ 标准字符串扩展。
YModules.h
YSLib::level
YF_API size_t level
Definition: YException.h:141
YSLib::FetchAppInstance
YF_API Application & FetchAppInstance()
取应用程序实例。
Definition: GUIApplication.cpp:295
NPL::c_str
YF_API const char src c_str())) YF_API void InstallDirectory(const string &
安装目录：复制目录树。
YSLib::InitializeSystemFontCache
YF_API void InitializeSystemFontCache(Drawing::FontCache &, const string &, const string &)
初始化系统字体缓存。
Definition: Initialization.cpp:436
platform::terminate
YB_NORETURN YF_API void terminate() ynothrow
异常终止函数。
Definition: YCommon.cpp:42
YSLib::ValueNode
值类型节点。
Definition: ValueNode.h:57
YSLib::ExtractInitException
YF_API void ExtractInitException(const std::exception &, string &) ynothrow
展开初始化异常。
Definition: Initialization.cpp:277
CHRLib::cp113
byte * cp113
Definition: MappingEx.cpp:57
YSLib::LoadConfiguration
YF_API ValueNode LoadConfiguration(bool={})
载入默认配置。
Definition: Initialization.cpp:411
platform::Descriptions::RecordLevel
RecordLevel
记录等级。
Definition: YCommon.h:151
platform::Descriptions::Notice
Definition: YCommon.h:158
YSLib::LoadNPLA1File
ValueNode LoadNPLA1File(const char *disp, const char *path, ValueNode(*creator)(), bool show_info)
Definition: Initialization.cpp:309
platform::bool
std::FILE *fp bool
Definition: FileIO.h:1187
YSLib::ExtractException
YF_API void ExtractException(const ExtractedLevelPrinter &, const std::exception &, RecordLevel=Err, size_t=0) ynothrow
展开指定层次的异常并使用指定参数记录。
YSLib::TraceForOutermost
YF_API void TraceForOutermost(const std::exception &, RecordLevel) ynothrow
处理最外层边界的异常，若捕获致命错误则在之后终止程序。
Definition: Initialization.cpp:286
YSLib::ExtractAndTrace
YF_API void ExtractAndTrace(const std::exception &, RecordLevel=Err) ynothrow
使用 TraceException 展开和跟踪异常类型和信息。