YSTest: Configuration.cpp 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

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

- 文件列表
- 文件成员

Configuration.cpp
浏览该文件的文档.
1 /*
2 © 2012-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 "NPL/YModules.h"
29 #include YFM_NPL_Configuration
30 #include YFM_NPL_SContext
31
32 using namespace YSLib;
33
34 namespace NPL
35 {
36
37 std::ostream&
38 operator<<(std::ostream& os, const Configuration& conf)
39 {
40 PrintNode(os, conf.GetRoot(), LiteralizeEscapeNodeLiteral);
41 return os;
42 }
43
44 std::istream&
45 operator>>(std::istream& is, Configuration& conf)
46 {
47 using sb_it_t = std::istreambuf_iterator<char>;
48 // TODO: Validate for S-expression?
49 Session sess(sb_it_t(is), sb_it_t{});
50
51 TryExpr(conf.root = A1::LoadNode(SContext::Analyze(std::move(sess))))
52 CatchExpr(..., ystdex::rethrow_badstate(is, std::ios_base::failbit))
53 return is;
54 }
55
56 } // namespace NPL;
57
ystdex::rethrow_badstate
void rethrow_badstate(std::basic_ios< _tChar, _tTraits > &ios, std::ios_base::iostate state=std::ios_base::badbit)
设置流状态并重新抛出当前异常。
Definition: ios.hpp:64
NPL::Configuration::root
ValueNode root
Definition: NPL/Configuration.h:45
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
CatchExpr
#define CatchExpr(_ex,...)
指定表达式作为异常处理器。
Definition: YBaseMacro.h:129
NPL::operator<<
std::ostream & operator<<(std::ostream &os, const Configuration &conf)
Definition: Configuration.cpp:38
NPL::PrintNode
YF_API void PrintNode(std::ostream &, const ValueNode &, NodeToString=EscapeNodeLiteral, IndentGenerator=DefaultGenerateIndent, size_t=0)
打印 NPLA 节点。
Definition: NPLA.cpp:100
TryExpr
#define TryExpr(...)
指定表达式在 try 块中求值。
Definition: YBaseMacro.h:120
YModules.h
NPL::LiteralizeEscapeNodeLiteral
YF_API string LiteralizeEscapeNodeLiteral(const ValueNode &)
转义 NPLA 节点字面量。
Definition: NPLA.cpp:74
NPL::operator>>
std::istream & operator>>(std::istream &is, Configuration &conf)
Definition: Configuration.cpp:45
NPL
Definition: NPL/Configuration.h:34
NPL::Configuration
设置：使用 S 表达式存储外部状态。
Definition: NPL/Configuration.h:42
NPL::SContext::Analyze
YF_API void Analyze(TermNode &, const TokenList &)
分析指定源，取抽象语法树储存至指定值类型节点。
Definition: SContext.cpp:92
NPL::A1::LoadNode
ValueNode LoadNode(_type &&tree, _tParams &&...args)
加载 NPLA1 翻译单元。
Definition: NPLA1.h:126