YSTest: Configuration.h 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

NPL/Configuration.h
浏览该文件的文档.
1 /*
2 © 2012-2016, 2019-2020 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 #ifndef NPL_INC_Configuration_h_
29 #define NPL_INC_Configuration_h_
30
31 #include "YModules.h"
32 #include YFM_NPL_NPLA1 // for NoContainer, ystdex::exclude_self_params_t;
33
34 namespace NPL
35 {
36
38 namespace A1
39 {
40
46 template<typename _type, typename... _tParams>
47 YB_ATTR_nodiscard ValueNode
48 LoadNode(_type&& tree, _tParams&&... args)
49 {
50 TryRet(A1::TransformNode(std::forward<TermNode>(tree), yforward(args)...))
51 CatchThrow(bad_any_cast& e, LoggedEvent(YSLib::sfmt(
52 "Bad NPLA1 tree found: cast failed from [%s] to [%s] .", e.from(),
53 e.to()), YSLib::Warning))
54 }
55
56 } // namespace A1;
57
58
64 class YF_API Configuration
65 {
66 private:
67 ValueNode root;
68
69 public:
70 DefDeCtor(Configuration)
72
73 Configuration(const ValueNode& node)
74 : root(node)
75 {}
76 Configuration(ValueNode&& node)
77 : root(std::move(node))
78 {}
80 template<typename... _tParams, yimpl(typename
82 = ystdex::exclude_self_params_t<Configuration, _tParams...>)>
83 explicit
84 Configuration(_tParams&&... args)
85 : root(NoContainer, yforward(args)...)
86 {}
87 DefDeCopyMoveCtorAssignment(Configuration)
88
89 DefGetter(const ynothrow, const ValueNode&, Root, root)
90
97 YF_API friend std::istream&
98 operator>>(std::istream&, Configuration&);
99
101 DefGetter(const ynothrow, const ValueNode&, Node, root)
106 DefGetter(ynothrow, ValueNode&&, NodeRRef, std::move(root))
107 };
108
114 YF_API std::ostream&
115 operator<<(std::ostream&, const Configuration&);
116
117 } // namespace NPL;
118
119 #endif
120
NPL::Configuration::DefDeCopyMoveCtorAssignment
DefDeCopyMoveCtorAssignment(Configuration) DefGetter(const ynothrow
YB_ATTR_nodiscard
#define YB_ATTR_nodiscard
标记返回值不被忽略的属性。
Definition: ydef.h:715
CHRLib::e
const char const char * e
Definition: CharacterProcessing.h:112
ystdex::exclude_self_params_t
enable_if_t< not_< cond_or_t< bool_< sizeof...(_tParams)==1 >, false_, is_same_param, _tSelected, _tParams... > >::value, void > exclude_self_params_t
排除选择类型的特定参数类型的重载。
Definition: type_op.hpp:295
NPL::Configuration::root
ValueNode root
Definition: NPL/Configuration.h:67
YF_API
#define YF_API
Definition: Platform.h:56
NPL::A1::TransformNode
YF_API ValueNode TransformNode(const TermNode &)
变换 NPLA1 节点 S 表达式抽象语法树为 NPLA1 语义结构。
Definition: NPLA1.cpp:1035
CHRLib::args
YB_ATTR_nodiscard _tParams && args
Definition: CharacterProcessing.h:649
YSLib::LoggedEvent
记录日志的异常事件类。
Definition: YException.h:51
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 转发对应参数。
Definition: ydef.h:1508
NPL::Configuration::Configuration
Configuration(ValueNode &&node)
Definition: NPL/Configuration.h:76
NPL::Configuration::Configuration
Configuration(_tParams &&... args)
Definition: NPL/Configuration.h:84
NPL::Configuration
设置：使用 S 表达式存储外部状态。
Definition: NPL/Configuration.h:65
YSLib::ValueNode
值类型节点。
Definition: ValueNode.h:73
std
Definition: optional.h:982
ystdex::sfmt
_tString sfmt(const typename string_traits< _tString >::value_type *fmt,...)
以 C 标准输出格式的输出 basic_string 实例的对象。
Definition: string.hpp:2028
NPL
Definition: NPL/Configuration.h:35
CatchThrow
#define CatchThrow(_ex,...)
指定抛出指定异常作为异常处理器。
Definition: YBaseMacro.h:141
platform::Descriptions::Warning
@ Warning
Definition: YCommon.h:183
YModules.h
YSLib 用户界面模块配置文件。
YSLib::_tParams
YB_ATTR_nodiscard YB_PURE typename _tParams
Definition: ValueNode.h:1294
NPL::A1::LoadNode
YB_ATTR_nodiscard ValueNode LoadNode(_type &&tree, _tParams &&... args)
加载 NPLA1 翻译单元。
Definition: NPL/Configuration.h:48
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:241
NPL::Configuration::DefDeCtor
DefDeCtor(Configuration) Configuration(const ValueNode &node)
Definition: NPL/Configuration.h:70
const
const Decapsulate const Decapsulate &y ynothrow ContextNode &ctx const
Definition: NPLA1Forms.cpp:1629
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:1199
TryRet
#define TryRet(...)
指定表达式在 try 块中求值并返回。
Definition: YBaseMacro.h:124
YSLib::NoContainer
yconstexpr const struct YSLib::NoContainerTag NoContainer
NPL::yimpl
yimpl(using) Reducer
规约器：和绑定上下文以外参数的求值遍的处理器具有等价签名的多态函数。
NPL::A1::args
const char _tParams && args
Definition: NPLA1.h:1877