YSTest: Initialization.cpp 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

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

- 文件列表
- 文件成员

Initialization.cpp
浏览该文件的文档.
1 /*
2 © 2009-2017 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 // for ystdex::nptr;
30 #include YFM_YSLib_Core_YException // for ExtractException, ExtractAndTrace;
31 #include YFM_CHRLib_MappingEx // for CHRLib::cp113_lkp;
32 #include YFM_YSLib_Service_TextFile // for Text::BOM_UTF_8, Text::CheckBOM;
33 #include YFM_NPL_Configuration // for NPL::Configuration;
34 #include <ystdex/string.hpp> // for ystdex::write_literal, ystdex::sfmt;
35 #include <ystdex/scope_guard.hpp> // for ystdex::swap_guard;
36 #include <cerrno> // for errno;
37 #include YFM_YSLib_Service_FileSystem // for IO::TraverseChildren;
38 #include YFM_Helper_GUIApplication // for FetchEnvironment, FetchAppInstance,
39 // Application::AddExit, Application::AddExitGuard;
40 #include YFM_Helper_Environment // for Environment;
41 #if YCL_Win32
42 # include YFM_Win32_YCLib_NLS // for platform_ex::FetchDBCSOffset,
43 // platform_ex::WCSToUTF8, platform_ex::UTF8ToWCS;
44 #endif
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_Linux
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 {
117 image.pop_back();
118
119 const auto& dir(image.Verify());
120
121 if(!dir.empty() && dir.back() == FetchSeparator<char16_t>())
122 return dir.GetMBCS();
123 }
124 # elif YCL_Android
125 const char*
126 sd_paths[]{"/sdcard/", "/mnt/sdcard/", "/storage/sdcard0/"};
127
128 for(const auto& path : sd_paths)
129 if(IO::VerifyDirectory(path))
130 {
131 YTraceDe(Informative, "Successfully found SD card path"
132 " '%s' as root path.", path);
133 return path;
134 }
135 else
136 YTraceDe(Informative,
137 "Failed accessing SD card path '%s'.", path);
138 # elif YCL_Linux
139 // FIXME: What if link reading failed (i.e. permission denied)?
140 // XXX: Link content like 'node_type:[inode]' is not supported.
141 // TODO: Use implemnetation for BSD family OS, etc.
142 auto image(IO::ResolvePath<ystdex::path<vector<string>,
143 IO::PathTraits>>(string_view("/proc/self/exe")));
144
145 if(!image.empty())
146 {
147 image.pop_back();
148
149 const auto& dir(IO::VerifyDirectoryPathTail(
150 ystdex::to_string_d(image)));
151
152 if(!dir.empty() && dir.back() == FetchSeparator<char>())
153 return dir;
154 }
155 # else
156 # error "Unsupported platform found."
157 # endif
158 throw GeneralEvent("Failed finding working root path.");
159 }())
160 {
161 YTraceDe(Informative, "Initialized root directory path '%s'.",
162 Path.c_str());
163 }
164 } init;
165
166 return init.Path;
167 }
168
169 // TODO: Reduce overhead?
170 # define CONF_PATH (FetchWorkingRoot() + "yconf.txt").c_str()
171 #endif
172 #if YCL_DS
173 # define DATA_DIRECTORY "/Data/"
174 # define DEF_FONT_DIRECTORY "/Font/"
175 # define DEF_FONT_PATH "/Font/FZYTK.TTF"
176 #elif YCL_Win32
177 # define DATA_DIRECTORY FetchWorkingRoot()
178 # define DEF_FONT_PATH (FetchSystemFontDirectory_Win32() + "SimSun.ttc")
179 inline PDefH(string, FetchSystemFontDirectory_Win32, )
181 // NOTE: Hard-coded as Shell32 special path with %CSIDL_FONTS or
182 // %CSIDL_FONTS. See https://msdn.microsoft.com/en-us/library/dd378457.aspx.
183 ImplRet(platform_ex::WCSToUTF8(platform_ex::FetchWindowsPath()) + "Fonts\\")
184 #elif YCL_Android
185 # define DATA_DIRECTORY (FetchWorkingRoot() + "Data/")
186 # define DEF_FONT_DIRECTORY "/system/fonts/"
187 # define DEF_FONT_PATH "/system/fonts/DroidSansFallback.ttf"
188 #elif YCL_Linux
189 # define DATA_DIRECTORY FetchWorkingRoot()
190 # define DEF_FONT_PATH "./SimSun.ttc"
191 #else
192 # error "Unsupported platform found."
193 #endif
194 #ifndef CONF_PATH
195 # define CONF_PATH "yconf.txt"
196 #endif
197 #ifndef DATA_DIRECTORY
198 # define DATA_DIRECTORY "./"
199 #endif
200 #ifndef DEF_FONT_DIRECTORY
201 # define DEF_FONT_DIRECTORY DATA_DIRECTORY
202 #endif
203
204 #if !CHRLib_NoDynamic_Mapping
205 MappedFile
207 LoadMappedModule(const string& path)
208 {
209 TryRet(MappedFile(path))
210 CatchExpr(..., std::throw_with_nested(
211 GeneralEvent("Loading module '" + path + "' failed.")))
212 YAssert(false, "Unreachable control found.");
213 }
214
215 # if YCL_Win32
216 const unsigned short* p_dbcs_off_936;
218 # endif
219
221 class CMap final
222 {
223 private:
224 MappedFile mapped{};
225 # if YCL_Win32
226 ystdex::nptr<char16_t(*)(byte, byte)> cp113_lkp_backup = {};
227 # endif
228
229 public:
230 CMap(const string& data_dir)
231 {
232 const string mapping_name(data_dir + "cp113.bin");
233
234 YTraceDe(Notice, "Loading character mapping file '%s' ...",
235 mapping_name.c_str());
236 try
237 {
238 mapped = LoadMappedModule(data_dir + "cp113.bin");
239 if(mapped.GetSize() != 0)
240 CHRLib::cp113 = mapped.GetPtr();
241 else
242 throw GeneralEvent("Failed loading CHRMapEx.");
243 YTraceDe(Notice, "CHRMapEx loaded successfully.");
244 }
245 catch(std::exception& e)
246 {
247 YTraceDe(Notice, "Module cp113.bin loading failed, error: %s",
248 e.what());
249 # if YCL_Win32
250 if((p_dbcs_off_936 = platform_ex::FetchDBCSOffset(936)))
251 {
252 cp113_lkp_backup = CHRLib::cp113_lkp;
253 CHRLib::cp113_lkp = [](byte seq0, byte seq1) ynothrowv
254 -> char16_t{
255 return p_dbcs_off_936[p_dbcs_off_936[seq0] + seq1];
256 };
257 }
258 if(p_dbcs_off_936)
259 YTraceDe(Notice, "NLS CP936 used as fallback.");
260 else
261 # endif
262 {
263 CHRLib::cp113_lkp = [](byte, byte) YB_ATTR(noreturn)
264 -> char16_t{
265 throw
266 LoggedEvent("Failed calling conversion for CHRMapEx.");
267 };
268 YTraceDe(Warning, "CHRMapEx conversion calls would lead to"
269 " exception thrown.");
270 }
271 }
272 }
273 ~CMap()
274 {
275 # if YCL_Win32
276 if(cp113_lkp_backup)
277 CHRLib::cp113_lkp = cp113_lkp_backup.get();
278 # endif
279 if(mapped)
280 {
281 mapped = MappedFile();
282 YTraceDe(Notice, "Character mapping deleted.");
283 }
284 }
285
286 DefDeMoveCtor(CMap)
287 };
288 #endif
289
291 void
292 WriteNPLA1Stream(std::ostream& os, NPL::Configuration&& conf)
293 {
294 ystdex::write_literal(os, Text::BOM_UTF_8) << std::move(conf);
295 }
296
298 ValueNode
299 TryReadRawNPLStream(std::istream& is)
300 {
301 NPL::Configuration conf;
302
303 is >> conf;
304 YTraceDe(Debug, "Plain configuration loaded.");
305 if(!conf.GetNodeRRef().empty())
306 return conf.GetNodeRRef();
307 YTraceDe(Warning, "Empty configuration found.");
308 throw GeneralEvent("Invalid stream found when reading configuration.");
309 }
310
312 template<typename _type, typename _fLoader, typename _func>
313 _type&
314 FetchDefaultResource(_fLoader load, _func f)
315 {
316 static mutex mtx;
317 static observer_ptr<_type> p_res;
318 lock_guard<mutex> lck(mtx);
319
320 if(YB_UNLIKELY(!p_res))
321 {
322 // TODO: Simplify?
323 const auto p_locked(FetchAppInstance().LockAddExit(load()));
324
325 p_res = make_observer(&f(FetchRoot()["YFramework"], *p_locked));
326 }
327 #if YCL_DS
328 // XXX: Actually this should be set after %InitVideo call.
329 ShowInitializedLog = {};
330 #endif
331 return *p_res;
332 }
333
334 } // unnamed namespace;
335
336 void
337 InitializeKeyModule(std::function<void()> f, const char* sig,
338 const char* t, string_view sv)
339 {
340 string res;
341
342 try
343 {
344 f();
345 return;
346 }
347 CatchExpr(std::exception& e, ExtractException(
348 [&](const string& str, RecordLevel, size_t level){
349 res += string(level, ' ') + "ERROR: " + str + '\n';
350 }, e))
351 CatchExpr(..., res += string("Unknown exception @ ") + sig + ".\n")
352 throw FatalError(t, sv.to_string() + res);
353 }
354
355 void
356 TraceForOutermost(const std::exception& e, RecordLevel lv) ynothrow
357 {
358 #if YCL_DS
359 ShowInitializedLog = {};
360 #endif
361 if(const auto p = dynamic_cast<const YSLib::FatalError*>(&e))
362 {
363 #if YCL_Win32
364 using platform_ex::UTF8ToWCS;
365
366 FilterExceptions([&]{
367 ::MessageBoxW({}, UTF8ToWCS(p->GetContent()).c_str(),
368 UTF8ToWCS(p->GetTitle()).data(), MB_ICONERROR);
369 });
370 #endif
371 YTraceDe(Emergent, "%s\n\n%s", p->GetTitle(), p->GetContent().data());
372 terminate();
373 }
374 else
375 ExtractAndTrace(e, lv);
376 }
377
378 ValueNode
379 LoadNPLA1File(const char* disp, const char* path, ValueNode(*creator)(),
380 bool show_info)
381 {
382 auto res(TryInvoke([=]() -> ValueNode{
383 if(!ufexists(path))
384 {
385 YTraceDe(Debug, "Path '%s' access failed.", path);
386 if(show_info)
387 YTraceDe(Notice, "Creating %s '%s'...", disp, path);
388
389 ystdex::swap_guard<int, void, decltype(errno)&> gd(errno, 0);
390
391 // XXX: Failed on race condition detected.
392 if(UniqueLockedOutputFileStream uofs{std::ios_base::out
393 | std::ios_base::trunc | platform::ios_noreplace, path})
394 WriteNPLA1Stream(uofs, Nonnull(creator)());
395 else
396 {
397 YTraceDe(Warning, "Cannot create file, possible error"
398 " (from errno) = %d: %s.", errno, std::strerror(errno));
399 YTraceDe(Warning,"Creating default file failed.");
400 return {};
401 }
402 YTraceDe(Debug, "Created configuration.");
403 }
404 if(show_info)
405 YTraceDe(Notice, "Found %s '%s'.", Nonnull(disp), path);
406 // XXX: Race condition may cause failure, though file would not be
407 // corrupted now.
408 if(SharedInputMappedFileStream sifs{path})
409 {
410 YTraceDe(Debug, "Accessible configuration file found.");
411 if(Text::CheckBOM(sifs, Text::BOM_UTF_8))
412 return TryReadRawNPLStream(sifs);
413 YTraceDe(Warning, "Wrong encoding of configuration file found.");
414 }
415 YTraceDe(Err, "Configuration corrupted.");
416 return {};
417 }));
418
419 if(res)
420 return res;
421 YTraceDe(Notice, "Trying fallback in memory...");
422
423 std::stringstream ss;
424
425 ss << Nonnull(creator)();
426 return TryReadRawNPLStream(ss);
427 }
428
429 void
430 LoadComponents(Application& app, const ValueNode& node)
431 {
432 const auto& data_dir(AccessChild<string>(node, "DataDirectory"));
433 const auto& font_path(AccessChild<string>(node, "FontFile"));
434 const auto& font_dir(AccessChild<string>(node, "FontDirectory"));
435
436 if(!data_dir.empty() && !font_path.empty() && !font_dir.empty())
437 YTraceDe(Notice, "Loaded default directory:\n%s\nLoaded default"
438 " font path:\n%s\nLoaded default font directory:\n%s",
439 data_dir.c_str(), font_path.c_str(), font_dir.c_str());
440 else
441 throw GeneralEvent("Empty path loaded.");
442 #if !CHRLib_NoDynamicMapping
443 app.AddExit(CMap(data_dir));
444 #endif
445 YTraceDe(Notice, "Trying entering directory '%s' ...", data_dir.c_str());
446 if(!IO::VerifyDirectory(data_dir))
447 throw GeneralEvent("Invalid default data directory found.");
448 if(!(ufexists(font_path.c_str()) || IO::VerifyDirectory(font_dir)))
449 throw GeneralEvent("Invalid default font file path found.");
450 }
451
452 ValueNode
453 LoadConfiguration(bool show_info)
454 {
455 return LoadNPLA1File("configuration file", CONF_PATH, []{
456 return ValueNode(NodeLiteral{"YFramework",
457 {{"DataDirectory", DATA_DIRECTORY}, {"FontFile", DEF_FONT_PATH},
458 {"FontDirectory", DEF_FONT_DIRECTORY}}});
459 }, show_info);
460 }
461
462 void
463 SaveConfiguration(const ValueNode& node)
464 {
465 if(UniqueLockedOutputFileStream
466 uofs{std::ios_base::out | std::ios_base::trunc, CONF_PATH})
467 {
468 YTraceDe(Debug, "Writing configuration...");
469 WriteNPLA1Stream(uofs, ValueNode(node.GetContainer()));
470 }
471 else
472 throw GeneralEvent("Invalid file found when writing configuration.");
473 YTraceDe(Debug, "Writing configuration done.");
474 }
475
476
477 void
478 InitializeSystemFontCache(FontCache& fc, const string& font_file,
479 const string& font_dir)
480 {
481 string res;
482
483 YTraceDe(Notice, "Loading font files...");
484 InitializeKeyModule([&]{
485 size_t loaded(fc.LoadTypefaces(font_file) != 0 ? 1 : 0);
486
487 if(!font_dir.empty())
488 try
489 {
490 IO::TraverseChildren(font_dir,
491 [&](NodeCategory c, NativePathView npv){
492 if(!bool(c & NodeCategory::Directory))
493 {
494 const FontPath path(font_dir + String(npv).GetMBCS());
495
496 if(path != font_file && fc.LoadTypefaces(path) != 0)
497 ++loaded;
498 }
499 });
500 }
501 CatchExpr(std::system_error& e, YTraceDe(Warning,
502 "Failed loading font directory."), ExtractAndTrace(e, Warning))
503 fc.InitializeDefaultTypeface();
504
505 const auto faces(fc.GetFaces().size());
506
507 if(faces != 0)
508 YTraceDe(Notice, "%zu face(s) in %zu font file(s)"
509 " are loaded\nsuccessfully.\n", faces, loaded);
510 else
511 throw GeneralEvent("No fonts found.");
512 YTraceDe(Notice, "Setting default font face...");
513 if(const auto pf = fc.GetDefaultTypefacePtr())
514 YTraceDe(Notice, "\"%s\":\"%s\",\nsuccessfully.",
515 pf->GetFamilyName().c_str(), pf->GetStyleName().c_str());
516 else
517 throw GeneralEvent("Setting default font face failed.");
518 }, yfsig, " Font Caching Failure ",
519 " Please make sure the fonts are\n stored in correct path.\n");
520 }
521
522
523 ValueNode&
524 FetchRoot() ynothrow
525 {
526 return FetchEnvironment().Root;
527 }
528
529 Drawing::FontCache&
530 FetchDefaultFontCache()
531 {
532 return FetchDefaultResource<Drawing::FontCache>([]{
533 return make_unique<Drawing::FontCache>();
534 }, [](ValueNode& node, unique_ptr<Drawing::FontCache>& locked)
535 -> Drawing::FontCache&{
536 InitializeSystemFontCache(*locked,
537 AccessChild<string>(node, "FontFile"),
538 AccessChild<string>(node, "FontDirectory"));
539 return *locked.get();
540 });
541 }
542
543 MIMEBiMapping&
544 FetchMIMEBiMapping()
545 {
546 return FetchDefaultResource<MIMEBiMapping>([]{
547 return MIMEBiMapping();
548 }, [](ValueNode& node, MIMEBiMapping& locked) -> MIMEBiMapping&{
549 AddMIMEItems(locked, LoadNPLA1File("MIME database", (AccessChild<string>
550 (node, "DataDirectory") + "MIMEExtMap.txt").c_str(), []{
551 return A1::LoadNode(SContext::Analyze(NPL::Session(TU_MIME)));
552 }, true));
553 return locked;
554 });
555 }
556
557 } // namespace YSLib;
558
YSLib::FetchMIMEBiMapping
YF_API MIMEBiMapping & FetchMIMEBiMapping()
取 MIME 类型名和文件扩展名双向映射对象。
Definition: Initialization.cpp:544
YTraceDe
#define YTraceDe(...)
YCLib 默认调试跟踪。
Definition: Debug.h:313
DATA_DIRECTORY
#define DATA_DIRECTORY
Definition: Initialization.cpp:198
CONF_PATH
#define CONF_PATH
Definition: Initialization.cpp:195
YSLib::Drawing::FontCache::InitializeDefaultTypeface
void InitializeDefaultTypeface()
初始化默认字型。
Definition: Font.cpp:487
platform::Descriptions::Debug
Definition: YCommon.h:170
ystdex::basic_string_view
Definition: string_view.hpp:49
YSLib::UI::fc
fc
Definition: Console.h:93
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
YSLib::FetchDefaultFontCache
YF_API Drawing::FontCache & FetchDefaultFontCache()
取默认字体缓存。 字体缓存初始化失败。
Definition: Initialization.cpp:530
ystdex::make_observer
observer_ptr< _type > make_observer(_type *p)
Definition: pointer.hpp:326
platform
默认平台命名空间。
Definition: Container.h:47
YSLib::FatalError
致命错误。
Definition: YException.h:90
YSLib::Drawing::FontCache
字体缓存。
Definition: Font.h:460
yfsig
#define yfsig
展开为表示函数签名的预定义变量的宏。
Definition: ydef.h:728
CHRLib::f
f(d, s)
ystdex::write_literal
std::basic_ostream< _tChar, _tTraits > & write_literal(std::basic_ostream< _tChar, _tTraits > &os, const _tChar(&s)[_vN])
Definition: string.hpp:1005
NPL::Session
会话：分析指定 NPL 代码。
Definition: SContext.h:103
CHRLib::cp113
byte * cp113
Definition: MappingEx.cpp:57
YSLib::Drawing::FontCache::GetDefaultTypefacePtr
observer_ptr< const Typeface > GetDefaultTypefacePtr() const
取默认字型指针。 异常中立：初始化时发生的异常。
Definition: Font.cpp:419
DefDeMoveCtor
#define DefDeMoveCtor(_t)
Definition: YBaseMacro.h:167
YSLib::Text::CheckBOM
CheckBOM
Definition: TextFile.h:81
platform::Descriptions::Emergent
Definition: YCommon.h:163
YSLib::Drawing::FontCache::LoadTypefaces
size_t LoadTypefaces(const FontPath &)
从字体文件组中载入字型信息。
Definition: Font.cpp:443
YB_UNLIKELY
#define YB_UNLIKELY(_expr)
分支预测提示。
Definition: ydef.h:464
NPL::c_str
YF_API const char src c_str())) YF_API void InstallDirectory(const string &
安装目录：复制目录树。
Definition: Dependency.h:131
YSLib::MIMEBiMapping
MIME 和文件扩展名双向映射。
Definition: ContentType.h:44
YSLib::TryInvoke
ystdex::nonvoid_result_t< ystdex::result_of_t< _fCallable &&(_tParams &&...)> > TryInvoke(_fCallable &&f, _tParams &&...args) ynothrow
调用函数并尝试返回。
Definition: YException.h:186
YSLib::LoggedEvent
记录日志的异常事件类。
Definition: YException.h:50
ystdex::nptr::get
const pointer & get() const
Definition: pointer.hpp:160
TryRet
#define TryRet(...)
指定表达式在 try 块中求值并返回。
Definition: YBaseMacro.h:124
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:679
platform::containers::string
basic_string< char > string
Definition: Container.h:101
YSLib::AddMIMEItems
YF_API void AddMIMEItems(MIMEBiMapping &, const ValueNode &, MIMEBiMapping::MIMEType &&={})
根据 NPLA1 节点内容增加 MIME 映射。
Definition: ContentType.cpp:62
ystdex::data
auto data(_tRange &c) -> decltype(c.data())
Definition: range.hpp:280
ystdex::path_category::node
DEF_FONT_DIRECTORY
#define DEF_FONT_DIRECTORY
Definition: Initialization.cpp:201
platform_ex::Windows::WCSToUTF8
const char *str string_view sv WCSToUTF8
Definition: NLS.h:79
YB_ATTR
#define YB_ATTR(...)
GNU 风格属性。
Definition: ydef.h:353
platform::Descriptions::RecordLevel
RecordLevel
记录等级。
Definition: YCommon.h:161
NPL::A1::LoadNode
ValueNode LoadNode(_type &&tree, _tParams &&...args)
加载 NPLA1 翻译单元。
Definition: NPLA1.h:154
mapped
MappedFile mapped
Definition: Initialization.cpp:224
YSLib::level
YF_API size_t level
Definition: YException.h:142
YSLib::IO::VerifyDirectory
bool VerifyDirectory(const char *path)
Definition: YSLib/Service/FileSystem.cpp:95
YAssert
#define YAssert(_expr, _msg)
Definition: cassert.h:111
CHRLib::cp113_lkp
char16_t(* cp113_lkp)(byte, byte)
查找编码转换序列的实现。
Definition: MappingEx.cpp:64
YSLib::Application
程序实例。
Definition: YApplication.h:46
CatchExpr
#define CatchExpr(_ex,...)
指定表达式作为异常处理器。
Definition: YBaseMacro.h:129
YSLib::FilterExceptions
bool FilterExceptions(_func f, const char *desc={}, RecordLevel lv=Alert, ExceptionTracer trace=ExtractAndTrace) ynothrow
调用函数并过滤宿主异常。
Definition: YException.h:203
YSLib::IO::UniqueLockedOutputFileStream
独占锁定的文件输出流。
Definition: File.h:110
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:766
IO
ystdex
特性测试宏。
Definition: ydef.h:822
platform::sig
const string const char *sig const char * sig
Definition: Debug.h:473
YSLib::Application::AddExit
void AddExit(_tParam &&arg)
Definition: YApplication.h:109
Drawing
NPL::Configuration
设置：使用 S 表达式存储外部状态。
Definition: NPL/Configuration.h:42
ystdex::path
一般路径模板。
Definition: path.hpp:123
platform::Descriptions::Notice
Definition: YCommon.h:168
YSLib::InitializeKeyModule
YF_API void InitializeKeyModule(std::function< void()>, const char *, const char *, string_view)
初始化关键模块。
Definition: Initialization.cpp:337
ystdex::state_guard
使用临时状态暂存对象的作用域守护。
Definition: scope_guard.hpp:273
YSLib::Drawing::FontPath
string FontPath
字体文件路径。
Definition: Font.h:78
YSLib::InitializeSystemFontCache
YF_API void InitializeSystemFontCache(Drawing::FontCache &, const string &, const string &)
初始化系统字体缓存。
Definition: Initialization.cpp:478
YSLib::NodeLiteral
包装节点的组合字面量。
Definition: ValueNode.h:1246
ynothrowv
#define ynothrowv
YSLib 无异常抛出保证验证：有条件地使用无异常抛出规范。
Definition: ydef.h:786
string.hpp
ISO C++ 标准字符串扩展。
YSLib::creator
YF_API const char ValueNode(* creator)()
Definition: Initialization.h:77
CHRLib::e
const char const char * e
Definition: CharacterProcessing.h:109
platform_ex::Windows::UTF8ToWCS
UTF8ToWCS
Definition: NLS.h:72
YModules.h
platform_ex::Windows::FetchWindowsPath
YF_API wstring FetchWindowsPath(size_t=MAX_PATH)
取系统目录路径。
YSLib::IO::SharedInputMappedFileStream
共享锁定的文件映射输入流。
Definition: File.h:94
YSLib::ValueNode
值类型节点。
Definition: ValueNode.h:58
YSLib::Text::BOM_UTF_8
yconstexpr const char BOM_UTF_8[]
Definition: TextFile.h:69
YSLib::show_info
YF_API const char ValueNode(*) boo show_info)
Definition: Initialization.h:78
ystdex::byte
unsigned char byte
字节类型。
Definition: ydef.h:834
platform::Nonnull
_type && Nonnull(_type &&p) ynothrowv
断言并返回非空参数。
Definition: Debug.h:422
NPL
Definition: NPL/Configuration.h:34
YSLib::GeneralEvent
std::runtime_error GeneralEvent
一般运行时异常事件类。
Definition: YException.h:46
platform::Descriptions::Warning
Definition: YCommon.h:167
platform::Descriptions::Err
Definition: YCommon.h:166
scope_guard.hpp
作用域守护。
platform::terminate
YB_NORETURN YF_API void terminate() ynothrow
异常终止函数。
Definition: YCommon.cpp:47
platform_ex
平台扩展命名空间。
Definition: Android.h:45
ystdex::nptr
可空指针包装：满足 NullablePointer 要求同时满足转移后为空。
Definition: pointer.hpp:60
platform::Descriptions::Informative
Definition: YCommon.h:169
YSLib::Text::str
const char const char * str
Definition: TextFile.h:81
CHRLib::c
c
Definition: CharacterProcessing.h:81
YSLib::SaveConfiguration
YF_API void SaveConfiguration(const ValueNode &)
保存默认配置。
Definition: Initialization.cpp:463
YSLib::TraceForOutermost
YF_API void TraceForOutermost(const std::exception &, RecordLevel) ynothrow
处理最外层边界的异常，若捕获致命错误则在之后终止程序。
Definition: Initialization.cpp:356
YSLib::LoadConfiguration
YF_API ValueNode LoadConfiguration(bool={})
载入默认配置。
Definition: Initialization.cpp:453
CHRLib::char16_t
char16_t((*c_ptr<< CHAR_BIT)|c_ptr[1])) inline PDefH(char16_t
取 c_ptr 指向的小端序双字节字符。
platform::MappedFile
只读内存映射文件。
Definition: MemoryMapping.h:111
platform::ufexists
bool ufexists(const char *filename) ynothrowv
Definition: FileIO.cpp:948
YSLib::FetchRoot
YF_API ValueNode & FetchRoot() ynothrow
取值类型根节点。
Definition: Initialization.cpp:524
ystdex::observer_ptr
观察者指针：无所有权的智能指针。
Definition: pointer.hpp:201
YSLib::LoadNPLA1File
ValueNode LoadNPLA1File(const char *disp, const char *path, ValueNode(*creator)(), bool show_info)
Definition: Initialization.cpp:379
YSLib::path
YF_API const char * path
Definition: Initialization.h:77
YSLib::FetchAppInstance
YF_API Application & FetchAppInstance()
取应用程序实例。
Definition: GUIApplication.cpp:295
YSLib::ExtractAndTrace
YF_API void ExtractAndTrace(const std::exception &, RecordLevel=Err) ynothrow
使用 TraceException 展开和跟踪异常类型和信息。
YSLib::LoadComponents
YF_API void LoadComponents(Application &, const ValueNode &)
初始化应用程序组件。
Definition: Initialization.cpp:430
platform_ex::Windows::FetchModuleFileName
YF_API wstring FetchModuleFileName(::HMODULE={}, YSLib::RecordLevel=YSLib::Err)
取模块映像路径。
ystdex::string_view
basic_string_view< char > string_view
Definition: string_view.hpp:415
NPL::SContext::Analyze
YF_API void Analyze(TermNode &, const TokenList &)
分析指定源，取抽象语法树储存至指定值类型节点。
Definition: SContext.cpp:92
YSLib::ExtractException
YF_API void ExtractException(const ExtractedLevelPrinter &, const std::exception &, RecordLevel=Err, size_t=0) ynothrow
展开指定层次的异常并使用指定参数记录。
CHRLib::p
const auto p(d)
YSLib::lv
RecordLevel lv
Definition: YException.cpp:58
platform_ex::Windows::Directory
Definition: MinGW32.h:452
YSLib::Text::String
YSLib 标准字符串（使用 UCS-2 作为内部编码）。
Definition: YString.h:46