YSTest: SContext.cpp 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

SContext.cpp
浏览该文件的文档.
1 /*
2 © 2012-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 #include "NPL/YModules.h"
29 #include YFM_NPL_SContext // for ystdex::ref_eq, std::allocator_arg,
30 // YSLib::make_string_view;
31
32 using namespace YSLib;
33
34 namespace NPL
35 {
36
37 // XXX: Simplify with %CreateRecursively?
38 TermNode::Container
39 TermNode::ConCons(const ValueNode::Container& con)
40 {
41 Container res;
42
43 for(const auto& item : con)
44 res.emplace_back(ConCons(item.GetContainer()), item.Value);
45 return res;
46 }
47 TermNode::Container
48 TermNode::ConCons(ValueNode::Container&& con)
49 {
50 Container res;
51
52 for(auto& item : con)
53 res.emplace_back(ConCons(std::move(item.GetContainerRef())),
54 std::move(item.Value));
55 return res;
56 }
57 TermNode::Container
58 TermNode::ConCons(const ValueNode::Container& con, allocator_type a)
59 {
60 Container res(a);
61
62 for(const auto& item : con)
63 res.emplace_back(ConCons(item.GetContainer()), item.Value);
64 return res;
65 }
66 TermNode::Container
67 TermNode::ConCons(ValueNode::Container&& con, allocator_type a)
68 {
69 Container res(a);
70
71 for(auto& item : con)
72 res.emplace_back(ConCons(std::move(item.GetContainerRef())),
73 std::move(item.Value));
74 return res;
75 }
76
77 void
78 TermNode::MoveContent(TermNode&& node)
79 {
80 YAssert(!ystdex::ref_eq<>()(*this, node), "Invalid self move found.");
81
82 // NOTE: Similar to %ValueNode::MoveContent.
83 const auto t(std::move(GetContainerRef()));
84
85 SetContent(std::move(node));
86 }
87
88 void
89 TermNode::SwapContent(TermNode& term) ynothrowv
90 {
91 SwapContainer(term),
92 swap(Value, term.Value);
93 }
94
95 void
96 swap(TermNode& x, TermNode& y) ynothrowv
97 {
98 x.SwapContent(y);
99 }
100
101
102 void
103 ReaderState::UpdateLexeme(const string& lexeme)
104 {
105 if(lexeme.length() == 1)
106 {
107 const char c(lexeme.front());
108
109 if(c == LeftDelimiter)
110 ++LeftDelimiterCount;
111 else if(c == RightDelimiter)
112 ++RightDelimiterCount;
113 }
114 }
115
116 } // namespace NPL;
117
ystdex::mapped_set< ValueNode, ystdex::less<>, MappedSetTraits, allocator_type >
x
const EncapsulationBase & x
Definition: NPLA1Forms.cpp:1536
YSLib::swap
void swap(ValueNode &x, ValueNode &y) ynothrowv
Definition: ValueNode.cpp:95
CHRLib::c
c
Definition: CharacterProcessing.h:84
NPL::A1::Internals::term
_fCurrent TermNode &decltype(cur(term, ctx)) term
Definition: NPLA1Internals.h:593
YModules.h
NPL 库模块配置文件。
YSLib::YAssert
YAssert(!(v< Deref(a)), "Value less than lower bound found.")
NPL
Definition: NPL/Configuration.h:35
YSLib::UI::y
SPos SPos y
Definition: YWidget.cpp:44
ystdex::ref_eq
引用等价关系仿函数。
Definition: functor.hpp:450
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:46
ynothrowv
#define ynothrowv
YSLib 无异常抛出保证验证：有条件地使用无异常抛出规范。
Definition: ydef.h:1219
YSLib::a
YB_PURE const _type * a
Definition: YCoreUtilities.h:168