YSTest: ValueNode.h 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

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

- 文件列表
- 文件成员

ValueNode.h
浏览该文件的文档.
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 #ifndef YSL_INC_Core_ValueNode_h_
29 #define YSL_INC_Core_ValueNode_h_ 1
30
31 #include "YModules.h"
32 #include YFM_YSLib_Core_YObject
33 #include <ystdex/path.hpp>
34 #include <ystdex/set.hpp> // for ystdex::mapped_set;
35 #include <numeric> // for std::accumulate;
36
37 namespace YSLib
38 {
39
41
42 yconstexpr const struct ListContainerTag{} ListContainer{};
44
46 yconstexpr const struct NoContainerTag{} NoContainer{};
48
49
57 class YF_API ValueNode : private ystdex::totally_ordered<ValueNode>,
58 private ystdex::totally_ordered<ValueNode, string>
59 {
60 public:
61 using Container = ystdex::mapped_set<ValueNode, ystdex::less<>>;
63 using key_type = typename Container::key_type;
65 using iterator = Container::iterator;
67 using const_iterator = Container::const_iterator;
69 using reverse_iterator = Container::reverse_iterator;
71 using const_reverse_iterator = Container::const_reverse_iterator;
72
73 private:
74 string name{};
79 Container container{};
80
81 public:
83 ValueObject Value{};
84
85 DefDeCtor(ValueNode)
90 ValueNode(Container con)
91 : container(std::move(con))
92 {}
98 template<typename _tString, typename... _tParams>
99 inline
100 ValueNode(NoContainerTag, _tString&& str, _tParams&&... args)
101 : name(yforward(str)), Value(yforward(args)...)
102 {}
107 template<typename _tString, typename... _tParams>
108 ValueNode(Container con, _tString&& str, _tParams&&... args)
109 : name(yforward(str)), container(std::move(con)),
110 Value(yforward(args)...)
111 {}
116 template<typename _tIn>
117 inline
118 ValueNode(const pair<_tIn, _tIn>& pr)
119 : container(pr.first, pr.second)
120 {}
125 template<typename _tIn, typename _tString>
126 inline
127 ValueNode(const pair<_tIn, _tIn>& pr, _tString&& str)
128 : name(yforward(str)), container(pr.first, pr.second)
129 {}
135 template<typename... _tParams1, size_t... _vIdxSeq1>
136 inline
137 ValueNode(std::tuple<_tParams1...> args1)
138 : ValueNode(ystdex::index_sequence_for<_tParams1...>(),
139 ystdex::index_sequence<>(), ystdex::index_sequence<>(), args1,
140 std::tuple<>(), std::tuple<>())
141 {}
142 template<typename... _tParams1, size_t... _vIdxSeq1, typename... _tParams2,
143 size_t... _vIdxSeq2>
144 inline
145 ValueNode(std::tuple<_tParams1...> args1, std::tuple<_tParams2...> args2)
146 : ValueNode(ystdex::index_sequence_for<_tParams1...>(),
147 ystdex::index_sequence_for<_tParams2...>(), ystdex::index_sequence<>(),
148 args1, args2, std::tuple<>())
149 {}
150 template<typename... _tParams1, size_t... _vIdxSeq1, typename... _tParams2,
151 size_t... _vIdxSeq2, typename... _tParams3, size_t... _vIdxSeq3>
152 inline
153 ValueNode(std::tuple<_tParams1...> args1, std::tuple<_tParams2...> args2,
154 std::tuple<_tParams3...> args3)
155 : ValueNode(ystdex::index_sequence_for<_tParams1...>(),
156 ystdex::index_sequence_for<_tParams2...>(),
157 ystdex::index_sequence_for<_tParams3...>(), args1, args2, args3)
158 {}
159
160 private:
161 template<typename... _tParams1, size_t... _vIdxSeq1, typename... _tParams2,
162 size_t... _vIdxSeq2, typename... _tParams3, size_t... _vIdxSeq3>
163 inline
164 ValueNode(ystdex::index_sequence<_vIdxSeq1...>,
165 ystdex::index_sequence<_vIdxSeq2...>,
166 ystdex::index_sequence<_vIdxSeq3...>,
167 std::tuple<_tParams1...> args1,
168 std::tuple<_tParams2...> args2,
169 std::tuple<_tParams3...> args3)
170 : name(std::get<_vIdxSeq2>(args2)...),
171 container(std::get<_vIdxSeq1>(args1)...),
172 Value(std::get<_vIdxSeq3>(args3)...)
173 {}
175
176 public:
177 DefDeCopyMoveCtor(ValueNode)
178
179
183 PDefHOp(ValueNode&, =, ValueNode node) ynothrow
184 ImplRet(node.swap(*this), *this)
185
187 DefBoolNeg(explicit, bool(Value) || !container.empty())
188
190
191 PDefHOp(const ValueNode&, +=, const ValueNode& node)
192 ImplRet(Add(node), *this)
193 PDefHOp(const ValueNode&, +=, ValueNode&& node)
194 ImplRet(Add(std::move(node)), *this)
195
196 PDefHOp(const ValueNode&, -=, const ValueNode& node)
197 ImplRet(Remove(node), *this)
198 PDefHOp(const ValueNode&, -=, const string& str)
199 ImplRet(Remove(str), *this)
205 PDefHOp(ValueNode&, /=, const ValueNode& node)
206 ImplRet(*this %= node, *this)
207 PDefHOp(ValueNode&, /=, ValueNode&& node)
208 ImplRet(*this %= std::move(node), *this)
210
215 const ValueNode&
216 operator%=(const ValueNode&);
217 const ValueNode&
218 operator%=(const ValueNode&&);
220
221
223 friend PDefHOp(bool, ==, const ValueNode& x, const ValueNode& y) ynothrow
224 ImplRet(x.name == y.name)
226 friend PDefHOp(bool, ==, const ValueNode& x, const string& str) ynothrow
227 ImplRet(x.name == str)
228
230 friend PDefHOp(bool, <, const ValueNode& x, const ValueNode& y) ynothrow
231 ImplRet(x.name < y.name)
233 friend PDefHOp(bool, <, const ValueNode& x, const string& str) ynothrow
234 ImplRet(x.name < str)
236 friend PDefHOp(bool, >, const ValueNode& x, const string& str) ynothrow
237 ImplRet(x.name > str)
238
240 template<typename _tString>
241 ValueNode&
242 operator[](_tString&& str)
243 {
244 return *ystdex::try_emplace(container, str, NoContainer, yforward(str))
245 .first;
246 }
248 template<class _tCon>
249 const ValueNode&
250 operator[](const ystdex::path<_tCon>& pth)
251 {
252 auto p(this);
253
254 for(const auto& n : pth)
255 p = &(*p)[n];
256 return *p;
257 }
258
263 DefGetter(const ynothrow, const Container&, Container, container)
268 DefGetter(ynothrow, Container&, ContainerRef, container)
269 DefGetter(const ynothrow, const string&, Name, name)
270
272
273 PDefH(void, SetChildren, Container con)
275 ImplExpr(container = std::move(con))
276
277 PDefH(bool, Add, const ValueNode& node)
278 ImplRet(insert(node).second)
279 PDefH(bool, Add, ValueNode&& node)
280 ImplRet(insert(std::move(node)).second)
282 template<typename _tString, typename... _tParams>
283 inline bool
284 Add(_tString&& str, _tParams&&... args)
285 {
286 return AddValueTo(container, yforward(str), yforward(args)...);
287 }
288
290 template<typename _tString, typename... _tParams>
291 static bool
292 AddValueTo(Container& con, _tString&& str, _tParams&&... args)
293 {
294 const auto pr(con.equal_range(str));
295
296 if(pr.first == pr.second)
297 {
298 con.emplace_hint(pr.first, NoContainer, yforward(str),
299 yforward(args)...);
300 return true;
301 }
302 return {};
303 }
304
309 PDefH(void, Clear, ) ynothrow
310 ImplExpr(Value.Clear(), ClearContainer())
311
316 PDefH(void, ClearContainer, ) ynothrow
317 ImplExpr(container.clear())
319
325 template<typename _type, typename _tString, typename... _tParams>
326 inline _type&
327 Place(_tString&& str, _tParams&&... args)
328 {
329 return try_emplace(str, NoContainer, yforward(str), InPlaceTag<_type>(),
330 yforward(args)...).first->Value.template GetObject<_type>();
331 }
332
333 PDefH(bool, Remove, const ValueNode& node)
334 ImplRet(container.erase(node) != 0)
336
337 template<typename _tKey>
338 inline bool
339 Remove(const _tKey& k)
340 {
341 return ystdex::erase_first(container, k);
342 }
344
349 template<typename _func>
350 Container
351 SelectChildren(_func f) const
352 {
353 Container res;
354
355 ystdex::for_each_if(begin(), end(), f, [&](const ValueNode& nd){
356 res.insert(nd);
357 });
358 return res;
359 }
360
362
363 template<typename _func>
365 Container
366 SplitChildren(_func f)
367 {
368 Container res;
369
370 std::for_each(begin(), end(), [&](const ValueNode& nd){
371 container.emplace(NoContainer, res, nd.GetName());
372 });
373 ystdex::for_each_if(begin(), end(), f, [&, this](const ValueNode& nd){
374 const auto& child_name(nd.GetName());
375
376 Deref(res.find(child_name)).Value = std::move(nd.Value);
377 Remove(child_name);
378 });
379 return res;
380 }
381
383
384 PDefH(void, SwapContainer, ValueNode& node) ynothrow
386 ImplExpr(container.swap(node.container))
387
389 void
390 SwapContent(ValueNode&) ynothrow;
392
393
395
396 PDefH(iterator, begin, )
397 ImplRet(GetContainerRef().begin())
398 PDefH(const_iterator, begin, ) const
399 ImplRet(GetContainer().begin())
400
402 DefFwdTmpl(const, pair<iterator YPP_Comma bool>, emplace,
403 container.emplace(yforward(args)...))
404
406 DefFwdTmpl(, iterator, emplace_hint,
407 container.emplace_hint(yforward(args)...))
408
410 PDefH(bool, empty, ) const ynothrow
411 ImplRet(container.empty())
412
413 PDefH(iterator, end, )
414 ImplRet(GetContainerRef().end())
415 PDefH(const_iterator, end, ) const
416 ImplRet(GetContainer().end())
418
420 DefFwdTmpl(-> decltype(container.insert(yforward(args)...)), auto,
421 insert, container.insert(yforward(args)...))
422
424
425 template<typename _tKey, class _tParam>
426 yimpl(ystdex::enable_if_inconvertible_t)<_tKey&&, const_iterator,
427 std::pair<iterator, bool>>
428 insert_or_assign(_tKey&& k, _tParam&& arg)
429 {
430 return ystdex::insert_or_assign(container, yforward(k), yforward(arg));
431 }
432 template<typename _tKey, class _tParam>
433 iterator
434 insert_or_assign(const_iterator hint, _tKey&& k, _tParam&& arg)
435 {
436 return ystdex::insert_or_assign_hint(container, hint, yforward(k),
437 yforward(arg));
438 }
440
442
443 PDefH(reverse_iterator, rbegin, )
444 ImplRet(GetContainerRef().rbegin())
445 PDefH(const_reverse_iterator, rbegin, ) const
446 ImplRet(GetContainer().rbegin())
447
448 PDefH(reverse_iterator, rend, )
449 ImplRet(GetContainerRef().rend())
450 PDefH(const_reverse_iterator, rend, ) const
451 ImplRet(GetContainer().rend())
453
459 friend PDefH(ValueNode, set_value_move, ValueNode& node)
460 ImplRet({std::move(node.GetContainerRef()), node.GetName(),
461 std::move(node.Value)})
462
464 PDefH(size_t, size, ) const ynothrow
465 ImplRet(container.size())
466
471 void
472 swap(ValueNode&) ynothrow;
473
475
476 template<typename _tKey, typename... _tParams>
477 yimpl(ystdex::enable_if_inconvertible_t)<_tKey&&, const_iterator,
478 std::pair<iterator, bool>>
479 try_emplace(_tKey&& k, _tParams&&... args)
480 {
481 return ystdex::try_emplace(container, yforward(k), yforward(args)...);
482 }
483 template<typename _tKey, typename... _tParams>
484 iterator
485 try_emplace(const_iterator hint, _tKey&& k, _tParams&&... args)
486 {
487 return ystdex::try_emplace_hint(container, hint, yforward(k),
488 yforward(args)...);
489 }
491 };
492
494
495
497
502 template<typename _type>
503 inline _type&
504 Access(ValueNode& node)
505 {
506 return node.Value.Access<_type>();
507 }
508 template<typename _type>
509 inline const _type&
510 Access(const ValueNode& node)
511 {
512 return node.Value.Access<_type>();
513 }
515
517
518
520 template<typename _type>
521 inline observer_ptr<_type>
522 AccessPtr(ValueNode& node) ynothrow
523 {
524 return node.Value.AccessPtr<_type>();
525 }
526 template<typename _type>
527 inline observer_ptr<const _type>
528 AccessPtr(const ValueNode& node) ynothrow
529 {
530 return node.Value.AccessPtr<_type>();
531 }
533
535 template<typename _type>
536 inline observer_ptr<_type>
537 AccessPtr(observer_ptr<ValueNode> p_node) ynothrow
538 {
539 return p_node ? AccessPtr<_type>(*p_node) : nullptr;
540 }
541 template<typename _type>
542 inline observer_ptr<const _type>
543 AccessPtr(observer_ptr<const ValueNode> p_node) ynothrow
544 {
545 return p_node ? AccessPtr<_type>(*p_node) : nullptr;
546 }
548
549
550
552 inline DefSwap(ynothrow, ValueNode)
554
555
556
558
563 YF_API ValueNode&
565 AccessNode(ValueNode::Container*, const string&);
567 YF_API const ValueNode&
568 AccessNode(const ValueNode::Container*, const string&);
569 inline PDefH(ValueNode&, AccessNode, observer_ptr<ValueNode::Container> p_con,
570 const string& name)
571 ImplRet(AccessNode(p_con.get(), name))
572 inline PDefH(const ValueNode&, AccessNode,
573 observer_ptr<const ValueNode::Container> p_con, const string& name)
574 ImplRet(AccessNode(p_con.get(), name))
576 inline PDefH(ValueNode&, AccessNode, ValueNode::Container& con,
577 const string& name)
578 ImplRet(AccessNode(&con, name))
580 inline PDefH(const ValueNode&, AccessNode, const ValueNode::Container& con,
581 const string& name)
582 ImplRet(AccessNode(&con, name))
584
585 YF_API ValueNode&
586 AccessNode(ValueNode&, size_t);
587 YF_API const ValueNode&
588 AccessNode(const ValueNode&, size_t);
590 inline PDefH(ValueNode&, AccessNode, ValueNode& node,
591 const string& name)
592 ImplRet(AccessNode(node.GetContainerRef(), name))
593 inline PDefH(const ValueNode&, AccessNode, const ValueNode& node,
594 const string& name)
595 ImplRet(AccessNode(node.GetContainer(), name))
597 template<class _tNode, typename _tIn>
598 _tNode&&
599 AccessNode(_tNode&& node, _tIn first, _tIn last)
600 {
601 return std::accumulate(first, last, ystdex::ref(node),
602 [](_tNode&& nd, decltype(*first) c){
603 return ystdex::ref(AccessNode(nd, c));
604 });
605 }
607 template<class _tNode, typename _tRange,
608 yimpl(typename = typename ystdex::enable_if_t<
609 !std::is_constructible<const string&, const _tRange&>::value>)>
610 inline auto
611 AccessNode(_tNode&& node, const _tRange& c)
612 -> decltype(YSLib::AccessNode(yforward(node), begin(c), end(c)))
613 {
614 return YSLib::AccessNode(yforward(node), begin(c), end(c));
615 }
617
619
620 YF_API observer_ptr<ValueNode>
621 AccessNodePtr(ValueNode::Container&, const string&) ynothrow;
622 YF_API observer_ptr<const ValueNode>
623 AccessNodePtr(const ValueNode::Container&, const string&) ynothrow;
624 inline PDefH(observer_ptr<ValueNode>, AccessNodePtr,
625 ValueNode::Container* p_con, const string& name) ynothrow
626 ImplRet(p_con ? AccessNodePtr(*p_con, name) : nullptr)
627 inline PDefH(observer_ptr<const ValueNode>, AccessNodePtr,
628 const ValueNode::Container* p_con, const string& name) ynothrow
629 ImplRet(p_con ? AccessNodePtr(*p_con, name) : nullptr)
630 inline PDefH(observer_ptr<ValueNode>, AccessNodePtr,
631 observer_ptr<ValueNode::Container> p_con, const string& name) ynothrow
632 ImplRet(p_con ? AccessNodePtr(*p_con, name) : nullptr)
633 inline PDefH(observer_ptr<const ValueNode>, AccessNodePtr,
634 observer_ptr<const ValueNode::Container> p_con, const string& name) ynothrow
635 ImplRet(p_con ? AccessNodePtr(*p_con, name) : nullptr)
637
638 YF_API observer_ptr<ValueNode>
639 AccessNodePtr(ValueNode&, size_t);
640 YF_API observer_ptr<const ValueNode>
641 AccessNodePtr(const ValueNode&, size_t);
643 inline PDefH(observer_ptr<ValueNode>, AccessNodePtr, ValueNode& node,
644 const string& name)
645 ImplRet(AccessNodePtr(node.GetContainerRef(), name))
646 inline PDefH(observer_ptr<const ValueNode>, AccessNodePtr, const ValueNode& node,
647 const string& name)
648 ImplRet(AccessNodePtr(node.GetContainer(), name))
650 template<class _tNode, typename _tIn>
651 auto
652 AccessNodePtr(_tNode&& node, _tIn first, _tIn last)
653 -> decltype(make_obsrever(std::addressof(node)))
654 {
655 // TODO: Simplified using algorithm template?
656 for(auto p(make_observer(std::addressof(node))); p && first != last;
657 ++first)
658 p = AccessNodePtr(*p, *first);
659 return first;
660 }
662 template<class _tNode, typename _tRange,
663 yimpl(typename = typename ystdex::enable_if_t<
664 !std::is_constructible<const string&, const _tRange&>::value>)>
665 inline auto
666 AccessNodePtr(_tNode&& node, const _tRange& c)
667 -> decltype(YSLib::AccessNodePtr(yforward(node), begin(c), end(c)))
668 {
669 return YSLib::AccessNodePtr(yforward(node), begin(c), end(c));
670 }
671
673
684 template<typename _type, typename... _tParams>
685 inline _type&
686 AccessChild(ValueNode& node, _tParams&&... args)
687 {
688 return Access<_type>(AccessNode(node, yforward(args)...));
689 }
690 template<typename _type, typename... _tParams>
691 inline const _type&
692 AccessChild(const ValueNode& node, _tParams&&... args)
693 {
694 return Access<_type>(AccessNode(node, yforward(args)...));
695 }
697
699
700 template<typename _type, typename... _tParams>
701 inline observer_ptr<_type>
702 AccessChildPtr(ValueNode& node, _tParams&&... args) ynothrow
703 {
704 return AccessPtr<_type>(
705 AccessNodePtr(node.GetContainerRef(), yforward(args)...));
706 }
707 template<typename _type, typename... _tParams>
708 inline observer_ptr<const _type>
709 AccessChildPtr(const ValueNode& node, _tParams&&... args) ynothrow
710 {
711 return AccessPtr<_type>(
712 AccessNodePtr(node.GetContainer(), yforward(args)...));
713 }
714 template<typename _type, typename... _tParams>
715 inline observer_ptr<_type>
716 AccessChildPtr(ValueNode* p_node, _tParams&&... args) ynothrow
717 {
718 return p_node ? AccessChildPtr<_type>(*p_node, yforward(args)...) : nullptr;
719 }
720 template<typename _type, typename... _tParams>
721 inline observer_ptr<const _type>
722 AccessChildPtr(const ValueNode* p_node, _tParams&&... args) ynothrow
723 {
724 return p_node ? AccessChildPtr<_type>(*p_node, yforward(args)...) : nullptr;
725 }
727
728
729
730
732
733 inline PDefH(const ValueNode&, AsNode, const ValueNode& node)
735 ImplRet(node)
740 template<typename _tString, typename... _tParams>
741 inline ValueNode
742 AsNode(_tString&& str, _tParams&&... args)
743 {
744 return {NoContainer, yforward(str), yforward(args)...};
745 }
746
751 template<typename _tString, typename... _tParams>
752 inline ValueNode
753 MakeNode(_tString&& str, _tParams&&... args)
754 {
755 return {NoContainer, yforward(str), ystdex::decay_copy(args)...};
756 }
758
764 template<typename _tString, typename... _tParams>
765 inline ValueNode
766 StringifyToNode(_tString&& str, _tParams&&... args)
767 {
768 return {NoContainer, yforward(str), to_string(yforward(args)...)};
769 }
770
776 inline PDefH(const ValueNode&, UnpackToNode, const ValueNode& arg)
777 ImplRet(arg)
778 inline PDefH(ValueNode&&, UnpackToNode, ValueNode&& arg)
779 ImplRet(std::move(arg))
781
786 template<class _tPack>
787 inline ValueNode
788 UnpackToNode(_tPack&& pk)
789 {
790 return {0, get<0>(yforward(pk)),
791 ValueObject(ystdex::decay_copy(get<1>(yforward(pk))))};
792 }
793
799 template<typename _tElem>
800 inline ValueNode::Container
801 CollectNodes(std::initializer_list<_tElem> il)
802 {
803 return il;
804 }
805 template<typename... _tParams>
806 inline ValueNode::Container
807 CollectNodes(_tParams&&... args)
808 {
809 return {yforward(args)...};
810 }
812
817 template<typename _tString, typename... _tParams>
818 inline ValueNode
819 PackNodes(_tString&& name, _tParams&&... args)
820 {
821 return {CollectNodes(UnpackToNode(yforward(args))...), yforward(name)};
822 }
823
824
826
827 YF_API void
829 RemoveEmptyChildren(ValueNode::Container&) ynothrow;
830
836 YF_API void
837 RemoveHead(ValueNode::Container&) ynothrowv;
838 inline PDefH(void, RemoveHead, ValueNode& term) ynothrowv
839 ImplExpr(RemoveHead(term.GetContainerRef()))
841
842
843
850 YF_API bool
851 IsPrefixedIndex(string_view, char = '$');
852
861 YF_API string
862 MakeIndex(size_t);
863 inline PDefH(string, MakeIndex, const ValueNode::Container& con)
864 ImplRet(MakeIndex(con.size()))
865 inline PDefH(string, MakeIndex, const ValueNode& node)
866 ImplRet(MakeIndex(node.GetContainer()))
868
874 template<typename _tParam, typename... _tParams>
875 inline ValueNode
876 AsIndexNode(_tParam&& arg, _tParams&&... args)
877 {
878 return AsNode(MakeIndex(yforward(arg)), yforward(args)...);
879 }
880
881
888 using NodeSequence = yimpl(YSLib::vector)<ValueNode>;
889
890
895 class YF_API NodeLiteral final
896 {
897 private:
898 ValueNode node;
899
900 public:
902 NodeLiteral(const ValueNode& nd)
903 : node(nd)
904 {}
906 NodeLiteral(ValueNode&& nd)
907 : node(std::move(nd))
908 {}
909 NodeLiteral(const string& str)
910 : node(NoContainer, str)
911 {}
912 NodeLiteral(const string& str, string val)
913 : node(NoContainer, str, std::move(val))
914 {}
915 template<typename _tLiteral = NodeLiteral>
916 NodeLiteral(const string& str, std::initializer_list<_tLiteral> il)
917 : node(NoContainer, str, NodeSequence(il.begin(), il.end()))
918 {}
920 template<typename _tLiteral = NodeLiteral, class _tString,
921 typename... _tParams>
922 NodeLiteral(ListContainerTag, _tString&& str,
923 std::initializer_list<_tLiteral> il, _tParams&&... args)
924 : node(ValueNode::Container(il.begin(), il.end()), yforward(str),
925 yforward(args)...)
926 {}
927 DefDeCopyMoveCtorAssignment(NodeLiteral)
928
929 DefCvt(ynothrow, ValueNode&, node)
930 DefCvt(const ynothrow, const ValueNode&, node)
931 };
932
938 template<typename _tString, typename _tLiteral = NodeLiteral>
939 inline NodeLiteral
940 AsNodeLiteral(_tString&& name, std::initializer_list<_tLiteral> il)
941 {
942 return {ListContainer, yforward(name), il};
943 }
944
945 } // namespace YSLib;
946
947 #endif
948
YSLib::RemoveEmptyChildren
YF_API void RemoveEmptyChildren(ValueNode::Container &) ynothrow
移除空子节点。
Definition: ValueNode.cpp:132
YSLib::ValueNode::ValueNode
ValueNode(std::tuple< _tParams1... > args1)
原地构造：使用容器、名称和值的参数元组。
Definition: ValueNode.h:137
YSLib::NodeLiteral::NodeLiteral
NodeLiteral(const string &str)
Definition: ValueNode.h:909
YSLib::ValueNode::insert_or_assign
iterator insert_or_assign(const_iterator hint, _tKey &&k, _tParam &&arg)
Definition: ValueNode.h:434
NPL::term
const TermNode &term ValueNode &node const ValueNode &node const TermNode & term
Definition: SContext.h:72
YSLib::ValueNode::SelectChildren
Container SelectChildren(_func f) const
复制满足条件的子节点。
Definition: ValueNode.h:351
platform::p
while p p
Definition: YCLib/FileSystem.h:225
YSLib::RemoveHead
YF_API void RemoveHead(ValueNode::Container &) ynothrowv
移除首个子节点。
Definition: ValueNode.cpp:140
YSLib::Drawing::x
The boundary is out of the const Rect SDst SPos x
Definition: YDraw.h:127
YSLib::ValueNode::AccessChild
_type & AccessChild(ValueNode &node, _tParams &&...args)
访问子节点的指定类型对象。
Definition: ValueNode.h:686
ystdex::to_string
std::string to_string(const std::thread::id &)
转换 thread::id 为字符串表示。
YSLib::ValueNode::ValueNode
ValueNode(const pair< _tIn, _tIn > &pr)
构造：使用输入迭代器对。
Definition: ValueNode.h:118
ystdex::string_view
basic_string_view< char > string_view
Definition: string_view.hpp:415
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:653
YSLib::ValueNode::PDefH
PDefH(bool, Remove, const ValueNode &node) ImplRet(container.erase(node)!=0) template< typename _tKey > inline bool Remove(const _tKey &k)
Definition: ValueNode.h:333
ystdex::any_ops::in_place_t
Definition: any.h:83
ystdex::try_emplace
std::pair< typename _tAssocCon::iterator, bool > try_emplace(_tAssocCon &con, _tKey &&k, _tParams &&...args)
Definition: container.hpp:1170
YModules.h
YSLib::ValueNode::ValueNode
ValueNode(std::tuple< _tParams1... > args1, std::tuple< _tParams2... > args2, std::tuple< _tParams3... > args3)
Definition: ValueNode.h:153
ystdex::set_value_move
const _type & set_value_move(const _type &x)
转移集合元素。
Definition: set.hpp:49
ystdex::swap
void swap(container_adaptor< _tSeqCon > &x, container_adaptor< _tSeqCon > &y)
Definition: container.hpp:179
YSLib::ValueNode::ValueNode
ValueNode(ystdex::index_sequence< _vIdxSeq1... >, ystdex::index_sequence< _vIdxSeq2... >, ystdex::index_sequence< _vIdxSeq3... >, std::tuple< _tParams1... > args1, std::tuple< _tParams2... > args2, std::tuple< _tParams3... > args3)
Definition: ValueNode.h:164
ystdex::cpp2014::enable_if_t
typename enable_if< _bCond, _type >::type enable_if_t
Definition: type_traits.hpp:350
YSLib::MakeIndex
MakeIndex
Definition: ValueNode.h:865
YSLib::yimpl
YF_API yimpl(GUIApplication &) FetchGlobalInstance()
取全局应用程序实例。
NPL::A1::name
ctx const string & name
Definition: NPLA1.h:248
YSLib::NodeLiteral::NodeLiteral
NodeLiteral(ValueNode &&nd)
Definition: ValueNode.h:906
ystdex::decay_copy
enable_if_convertible_t< _type, decay_t< _type >, decay_t< _type > > decay_copy(_type &&arg)
退化复制。
Definition: utility.hpp:108
ystdex::mapped_set::equal_range
std::pair< iterator, iterator > equal_range(const key_type &x)
Definition: set.hpp:623
ystdex::nullptr
const class ystdex::nullptr_t nullptr
DefDeCopyMoveCtorAssignment
#define DefDeCopyMoveCtorAssignment(_t)
Definition: YBaseMacro.h:201
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
ystdex::enable_if_inconvertible_t
enable_if_t<!is_convertible< _tFrom, _tTo >::value, _type > enable_if_inconvertible_t
Definition: type_traits.hpp:998
YSLib::NodeLiteral::node
ValueNode node
Definition: ValueNode.h:898
YSLib::PDefH
PDefH(Environment &, FetchEnvironment,) ImplRet(FetchGlobalInstance().GetEnvironmentRef()) inline PDefH(GUIHost &
取单一环境对象引用。
YSLib::NodeLiteral::NodeLiteral
NodeLiteral(const ValueNode &nd)
Definition: ValueNode.h:902
ynothrowv
#define ynothrowv
YSLib 无异常抛出保证验证：有条件地使用无异常抛出规范。
Definition: ydef.h:760
YSLib::ValueNode::const_reverse_iterator
Container::const_reverse_iterator const_reverse_iterator
Definition: ValueNode.h:71
ystdex::mapped_set::reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
Definition: set.hpp:192
YSLib::ValueNode::ValueNode
ValueNode(NoContainerTag, _tString &&str, _tParams &&...args)
构造：使用字符串引用和值类型对象构造参数。
Definition: ValueNode.h:100
ystdex::details::insert_or_assign
std::pair< typename _tAssocCon::iterator, bool > insert_or_assign(std::pair< typename _tAssocCon::iterator, bool > pr, _tAssocCon &con, _tKey &&k, _tParam &&arg)
Definition: container.hpp:1031
ystdex::insert_or_assign
std::pair< typename _tAssocCon::iterator, bool > insert_or_assign(_tAssocCon &con, _tKey &&k, _tParam &&arg)
Definition: container.hpp:1196
ystdex::mapped_set::find
iterator find(const key_type &x)
Definition: set.hpp:516
YSLib::AccessNode
name name name name YF_API ValueNode & AccessNode(ValueNode &, size_t)
Definition: ValueNode.cpp:81
DefDeCopyMoveCtor
#define DefDeCopyMoveCtor(_t)
Definition: YBaseMacro.h:172
ystdex::try_emplace_hint
std::pair< typename _tAssocCon::iterator, bool > try_emplace_hint(_tAssocCon &con, typename _tAssocCon::const_iterator hint, _tKey &&k, _tParams &&...args)
Definition: container.hpp:1181
CHRLib::c
c
Definition: CharacterProcessing.h:81
YSLib::ValueNode::key_type
typename Container::key_type key_type
Definition: ValueNode.h:63
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:240
YSLib::ValueNode::DefDeCtor
DefDeCtor(ValueNode) ValueNode(Container con)
构造：使用容器对象。
Definition: ValueNode.h:85
ystdex::mapped_set
允许指定不同于值类型的键的集合。
Definition: set.hpp:160
YSLib::NodeLiteral
包装节点的组合字面量。
Definition: ValueNode.h:895
DefCvt
#define DefCvt(_q, _t,...)
Definition: YBaseMacro.h:205
YSLib::PackNodes
ValueNode PackNodes(_tString &&name, _tParams &&...args)
取以指定分量为参数对应初始化得到的值类型节点为子节点的值类型节点。
Definition: ValueNode.h:819
YSLib::ynothrow
YB_PURE const _type size_t n ynothrow
Definition: YCoreUtilities.h:168
YSLib::ValueNode::StringifyToNode
ValueNode StringifyToNode(_tString &&str, _tParams &&...args)
取指定名称和转换为字符串的值类型节点。
Definition: ValueNode.h:766
ystdex::cpp2014::index_sequence
integer_sequence< size_t, _vSeq... > index_sequence
Definition: integer_sequence.hpp:63
YSLib::ValueNode::Container
ystdex::mapped_set< ValueNode, ystdex::less<>> Container
Definition: ValueNode.h:61
YSLib::AccessNodePtr
name AccessNodePtr
Definition: ValueNode.h:627
std
Definition: memory.hpp:1100
platform::Deref
yconstfn auto Deref(_type &&p) -> decltype(*p)
断言并解引用非空指针。
Definition: Debug.h:440
YSLib::ValueNode::AddValueTo
static bool AddValueTo(Container &con, _tString &&str, _tParams &&...args)
Definition: ValueNode.h:292
YSLib::ValueNode::Access
_type & Access(ValueNode &node)
访问节点的指定类型对象。 空实例或类型检查失败 。
Definition: ValueNode.h:504
ystdex::mapped_set::emplace_hint
iterator emplace_hint(const_iterator position, _tParams &&...args)
Definition: set.hpp:381
YSLib::NodeLiteral::NodeLiteral
NodeLiteral(const string &str, std::initializer_list< _tLiteral > il)
Definition: ValueNode.h:916
path.hpp
抽象路径模板。
ystdex::size
auto size(const _tRange &c) -> decltype(c.size())
类容器访问。
Definition: range.hpp:233
set.hpp
集合容器。
ystdex::erase_first
bool erase_first(_tAssocCon &con, const _tKey &k)
删除指定关联容器中等价于指定键的起始元素。
Definition: container.hpp:745
YSLib::IsPrefixedIndex
bool IsPrefixedIndex(string_view name, char prefix)
Definition: ValueNode.cpp:148
ystdex::mapped_set::key_type
_type key_type
Definition: set.hpp:163
ystdex::mapped_set::const_reverse_iterator
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: set.hpp:193
ystdex::for_each_if
_func for_each_if(_tIn first, _tIn last, _fPred pred, _func f)
Definition: algorithm.hpp:158
YSLib::CollectNodes
ValueNode::Container CollectNodes(std::initializer_list< _tElem > il)
取指定值类型节点为成员的节点容器。
Definition: ValueNode.h:801
ystdex::path
一般路径模板。
Definition: path.hpp:123
ystdex
特性测试宏。
Definition: ydef.h:796
YSLib::Text::str
const char const char * str
Definition: TextFile.h:77
YSLib::ValueNode::ValueNode
ValueNode(Container con, _tString &&str, _tParams &&...args)
构造：使用容器对象、字符串引用和值类型对象构造参数。
Definition: ValueNode.h:108
YSLib::ValueNode::ValueNode
ValueNode(std::tuple< _tParams1... > args1, std::tuple< _tParams2... > args2)
Definition: ValueNode.h:145
YSLib::ValueNode::try_emplace
iterator try_emplace(const_iterator hint, _tKey &&k, _tParams &&...args)
Definition: ValueNode.h:485
YSLib::NodeLiteral::NodeLiteral
NodeLiteral(ListContainerTag, _tString &&str, std::initializer_list< _tLiteral > il, _tParams &&...args)
Definition: ValueNode.h:922
YSLib::ValueNode::AccessChildPtr
observer_ptr< _type > AccessChildPtr(ValueNode &node, _tParams &&...args) ynothrow
访问指定名称的子节点的指定类型对象的指针。
Definition: ValueNode.h:702
YSLib::ValueNode::ValueNode
ValueNode(const pair< _tIn, _tIn > &pr, _tString &&str)
构造：使用输入迭代器对、字符串引用和值参数。
Definition: ValueNode.h:127
YSLib::ValueNode::SplitChildren
Container SplitChildren(_func f)
转移满足条件的子节点。
Definition: ValueNode.h:366
YSLib::UI::y
SPos SPos y
Definition: YWidget.cpp:44
YSLib::ValueNode::Value
ValueObject Value
Definition: ValueNode.h:83
YSLib::UnpackToNode
UnpackToNode
Definition: ValueNode.h:778
YPP_Comma
#define YPP_Comma
替换为逗号的预处理记号。
Definition: ydef.h:225
YSLib::ListContainerTag
标记列表构造容器。
Definition: ValueNode.h:43
YSLib::p_con
name const ValueNode::Container * p_con
Definition: ValueNode.h:627
DefFwdTmpl
#define DefFwdTmpl(_q, _t, _n,...)
传递模板。
Definition: YBaseMacro.h:326
YSLib::NodeSequence
yimpl(YSLib::vector)< ValueNode > NodeSequence
节点序列容器。
Definition: ValueNode.h:888
YSLib::ValueNode::AccessPtr
observer_ptr< _type > AccessPtr(observer_ptr< ValueNode > p_node) ynothrow
访问节点的指定类型对象指针。
Definition: ValueNode.h:537
YSLib::ListContainer
yconstexpr const struct YSLib::ListContainerTag ListContainer
ystdex::cpp2014::rend
auto rend(_tRange &c) -> decltype(c.rend())
Definition: range.hpp:119
YSLib::ValueNode::MakeNode
ValueNode MakeNode(_tString &&str, _tParams &&...args)
传递指定名称和退化值参数构造值类型节点。
Definition: ValueNode.h:753
YSLib::ValueNode
值类型节点。
Definition: ValueNode.h:57
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
Definition: ydef.h:969
DefBoolNeg
#define DefBoolNeg(_spec,...)
定义表示显式转换 bool 操作符及其否定的 operator! 。
Definition: YBaseMacro.h:227
ystdex::make_observer
observer_ptr< _type > make_observer(_type *p)
Definition: memory.hpp:1042
YF_API
#define YF_API
Definition: Platform.h:56
YSLib::ValueObject::Access
const _type & Access() const
Definition: YObject.h:400
YSLib::NoContainerTag
标记不使用容器。
Definition: ValueNode.h:46
ystdex::cpp2014::index_sequence_for
make_index_sequence< sizeof...(_types)> index_sequence_for
Definition: integer_sequence.hpp:237
ystdex::cpp2011::begin
_type * begin(_type(&&array)[_vN])
Definition: range.hpp:46
ystdex::insert_or_assign_hint
std::pair< typename _tAssocCon::iterator, bool > insert_or_assign_hint(_tAssocCon &con, typename _tAssocCon::const_iterator hint, _tKey &&k, _tParam &&arg)
Definition: container.hpp:1204
ystdex::dep_ops::totally_ordered
details::flat_ops< _type, _type2, _tOpt, less_than_comparable, equality_comparable > totally_ordered
Definition: operators.hpp:367
YSLib::IO::f
const string &path const String &path _func f
Definition: YSLib/Service/FileSystem.h:430
ystdex::cpp2014::rbegin
auto rbegin(_tRange &c) -> decltype(c.rbegin())
Definition: range.hpp:94
CHRLib::args
_tParams && args
Definition: CharacterProcessing.h:538
ystdex::mapped_set::insert
std::pair< iterator, bool > insert(const value_type &x)
Definition: set.hpp:389
YSLib::ImplRet
ImplRet(FetchGlobalInstance().GetGUIHostRef()) YF_API void Execute(GUIApplication &
执行程序主消息循环。
YSLib::ValueObject
值类型对象类。
Definition: YObject.h:272
ystdex::cpp2011::end
_type * end(_type(&&array)[_vN])
Definition: range.hpp:54
YSLib::ValueNode::AccessPtr
observer_ptr< _type > AccessPtr(ValueNode &node) ynothrow
访问节点的指定类型对象指针。
Definition: ValueNode.h:522
YSLib::AsIndexNode
const ValueNode &node typename _tParams ValueNode AsIndexNode(_tParam &&arg, _tParams &&...args)
Definition: ValueNode.h:876
YSLib::ValueNode::reverse_iterator
Container::reverse_iterator reverse_iterator
Definition: ValueNode.h:69
YSLib::NodeLiteral::NodeLiteral
NodeLiteral(const string &str, string val)
Definition: ValueNode.h:912
platform::n
size_t n
Definition: YCLib/FileSystem.cpp:321
YSLib::NoContainer
yconstexpr const struct YSLib::NoContainerTag NoContainer
ystdex::transformed_iterator
变换迭代器。
Definition: iterator.hpp:216
ystdex::ref
lref< _type > ref(_type &t)
构造引用包装。
Definition: ref.hpp:120