The YSLib project - main repository
Revision | ad10f75265b27e76c825eb199bea076667b13ffb (tree) |
---|---|
Time | 2024-02-27 01:28:20 |
Author | FrankHB <frankhb1989@gmai...> |
Commiter | FrankHB |
更新主分支版本: build 982 rev 10 。
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2012-2015, 2018, 2022 FrankHB. | |
2 | + © 2012-2015, 2018, 2022-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file array.hpp |
12 | 12 | \ingroup YStandardEx |
13 | 13 | \brief 数组操作。 |
14 | -\version r175 | |
14 | +\version r180 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 532 |
17 | 17 | \par 创建时间: |
18 | 18 | 2014-09-01 18:39:25 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-06-05 01:40 +0800 | |
20 | + 2023-12-20 20:47 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -42,7 +42,7 @@ | ||
42 | 42 | \see WG21 N4315 。 |
43 | 43 | \since build 562 |
44 | 44 | */ |
45 | -//@{ | |
45 | +//!@{ | |
46 | 46 | /*! |
47 | 47 | \ingroup metafunctions |
48 | 48 | \brief 取指定类型和参数类型推断的 std::array 实例。 |
@@ -79,13 +79,13 @@ | ||
79 | 79 | { |
80 | 80 | return {{ystdex::decay_copy(args)...}}; |
81 | 81 | } |
82 | -//@} | |
82 | +//!@} | |
83 | 83 | |
84 | 84 | /*! |
85 | 85 | \brief 转换指定参数为 \c std::array 对象。 |
86 | 86 | \since build 337 |
87 | 87 | */ |
88 | -//@{ | |
88 | +//!@{ | |
89 | 89 | template<typename _type, size_t _vN, typename _tSrc> |
90 | 90 | yconstfn std::array<_type, _vN> |
91 | 91 | to_array(const _tSrc& src) |
@@ -128,7 +128,7 @@ | ||
128 | 128 | std::min(_vN, il.size()), std::addressof(arr[0])); |
129 | 129 | return arr; |
130 | 130 | } |
131 | -//@} | |
131 | +//!@} | |
132 | 132 | |
133 | 133 | } // namespace ystdex; |
134 | 134 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2013-2015, 2017-2019, 2021-2022 FrankHB. | |
2 | + © 2013-2015, 2017-2019, 2021-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file base.h |
12 | 12 | \ingroup YStandardEx |
13 | 13 | \brief 基类实用设施。 |
14 | -\version r262 | |
14 | +\version r270 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 556 |
17 | 17 | \par 创建时间: |
18 | 18 | 2014-11-28 11:59:15 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-02-08 03:15 +0800 | |
20 | + 2023-12-20 20:44 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -31,7 +31,7 @@ | ||
31 | 31 | https://stackoverflow.com/questions/10788823 的讨论。 |
32 | 32 | ISO C++20 的规则(自 WG21 P840R2 )进一步明确了空基类的情形,但没有实质变化。 |
33 | 33 | Microsoft VC++ 因为 ABI 兼容问题不会在短期实现符合 ISO C++11 要求的空基类优化, |
34 | - 而同时需要使用 __declspec(empty_bases) 变通,参见: | |
34 | + 而同时需要使用 __declspec(empty_bases) 变通,参见: | |
35 | 35 | https://devblogs.microsoft.com/cppblog/optimizing-the-layout-of-empty-base-classes-in-vs2015-update-2-3/ ; |
36 | 36 | https://developercommunity.visualstudio.com/t/no-unique-address-attribute-isnt-working/954963 。 |
37 | 37 | */ |
@@ -54,7 +54,7 @@ | ||
54 | 54 | { |
55 | 55 | |
56 | 56 | //! \warning 非虚析构。 |
57 | -//@{ | |
57 | +//!@{ | |
58 | 58 | /*! |
59 | 59 | \brief 不可复制对象:禁止派生类调用默认原型的复制构造函数和复制赋值操作符。 |
60 | 60 | \note WG21 N2600 在 ISO C++11 之前提议一个更简单的实现,但没有被标准采纳。 |
@@ -115,7 +115,7 @@ | ||
115 | 115 | |
116 | 116 | public: |
117 | 117 | //! \since build 551 |
118 | - //@{ | |
118 | + //!@{ | |
119 | 119 | //! \brief 允许复制构造。 |
120 | 120 | yconstfn |
121 | 121 | nonmovable(const nonmovable&) = default; |
@@ -129,9 +129,9 @@ | ||
129 | 129 | //! \brief 禁止转移赋值。 |
130 | 130 | nonmovable& |
131 | 131 | operator=(nonmovable&&) = delete; |
132 | - //@} | |
132 | + //!@} | |
133 | 133 | }; |
134 | -//@} | |
134 | +//!@} | |
135 | 135 | |
136 | 136 | |
137 | 137 | /*! |
@@ -227,7 +227,7 @@ | ||
227 | 227 | } // namespace bases; |
228 | 228 | |
229 | 229 | //! \since build 834 |
230 | -//@{ | |
230 | +//!@{ | |
231 | 231 | using noncopyable = bases::noncopyable; |
232 | 232 | |
233 | 233 | using nonmovable = bases::nonmovable; |
@@ -239,7 +239,7 @@ | ||
239 | 239 | |
240 | 240 | template<class _tBase, typename... _tParams> |
241 | 241 | using derived_entity = bases::derived_entity<_tBase, _tParams...>; |
242 | -//@} | |
242 | +//!@} | |
243 | 243 | |
244 | 244 | } // namespace ystdex; |
245 | 245 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2012, 2014-2015, 2018-2019, 2022 FrankHB. | |
2 | + © 2012, 2014-2015, 2018-2019, 2022-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file bind.hpp |
12 | 12 | \ingroup YStandardEx |
13 | 13 | \brief 函数部分应用。 |
14 | -\version r5305 | |
14 | +\version r5308 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 939 |
17 | 17 | \par 创建时间: |
18 | 18 | 2022-02-13 09:10:49 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-02-14 18:01 +0800 | |
20 | + 2023-12-20 20:47 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -38,7 +38,7 @@ | ||
38 | 38 | \brief 复合调用 std::bind 和 std::placeholders::_1 。 |
39 | 39 | \note ISO C++ 要求 std::placeholders::_1 被实现支持。 |
40 | 40 | */ |
41 | -//@{ | |
41 | +//!@{ | |
42 | 42 | //! \since build 628 |
43 | 43 | template<typename _func, typename... _tParams> |
44 | 44 | YB_ATTR_nodiscard YB_PURE inline auto |
@@ -56,7 +56,7 @@ | ||
56 | 56 | return |
57 | 57 | std::bind<_tRes>(yforward(f), std::placeholders::_1, yforward(args)...); |
58 | 58 | } |
59 | -//@} | |
59 | +//!@} | |
60 | 60 | |
61 | 61 | /*! |
62 | 62 | \brief 复合调用 ystdex::bind1 和 std::placeholders::_2 以实现值的设置。 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2015-2016, 2018-2022 FrankHB. | |
2 | + © 2015-2016, 2018-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file bit.hpp |
12 | 12 | \ingroup YStandardEx |
13 | 13 | \brief 位操作。 |
14 | -\version r1405 | |
14 | +\version r1419 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 245 |
17 | 17 | \par 创建时间: |
18 | 18 | 2021-12-18 22:57:19 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-11-28 19:03 +0800 | |
20 | + 2023-12-20 20:45 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -78,7 +78,7 @@ | ||
78 | 78 | |
79 | 79 | |
80 | 80 | //! \since build 695 |
81 | -//@{ | |
81 | +//!@{ | |
82 | 82 | namespace details |
83 | 83 | { |
84 | 84 |
@@ -113,7 +113,7 @@ | ||
113 | 113 | { |
114 | 114 | return bool(details::bit_order_tester{1}.le & 1); |
115 | 115 | } |
116 | -//@} | |
116 | +//!@} | |
117 | 117 | |
118 | 118 | |
119 | 119 | //! \brief 判断无符号整数是否为 2 的整数次幂。 |
@@ -139,14 +139,14 @@ | ||
139 | 139 | { |
140 | 140 | |
141 | 141 | //! \since build 933 |
142 | -//@{ | |
142 | +//!@{ | |
143 | 143 | // XXX: Current policy does not relies on features specific to concrete |
144 | 144 | // microarchitectures. Consideration of '__builtin_ia32_lzcnt_u*' and |
145 | 145 | // '__builtin_ia32_tzcnt_u*' is deferred. Note GCC 7.0 may not work, see |
146 | 146 | // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78057. |
147 | 147 | //! \pre <tt>x != 0</tt> 。 |
148 | -//@{ | |
149 | -// XXX: There is no use of %__builtin_clzs, since it is less portable. See | |
148 | +//!@{ | |
149 | +// XXX: There is no use of %__builtin_clzs, since it is less portable. | |
150 | 150 | # if !(__has_builtin(__builtin_clz) && __has_builtin(__builtin_clzl) \ |
151 | 151 | && __has_builtin(__builtin_clzll)) || !(YB_IMPL_GNUC >= 30400) |
152 | 152 | template<size_t> |
@@ -370,8 +370,8 @@ | ||
370 | 370 | return details::ctz(unsigned(x)) - (std::numeric_limits<unsigned>::digits |
371 | 371 | - std::numeric_limits<unsigned short>::digits); |
372 | 372 | } |
373 | -//@} | |
374 | -//@} | |
373 | +//!@} | |
374 | +//!@} | |
375 | 375 | |
376 | 376 | |
377 | 377 | //! \since build 849 |
@@ -391,7 +391,7 @@ | ||
391 | 391 | \pre <tt>x != 0</tt> 。 |
392 | 392 | \since build 933 |
393 | 393 | */ |
394 | -//@{ | |
394 | +//!@{ | |
395 | 395 | template<size_t _vN, typename _type> |
396 | 396 | YB_ATTR_nodiscard YB_ATTR_always_inline YB_STATELESS inline size_t |
397 | 397 | floor_lb_w(_type x, size_t_<_vN>) ynothrowv |
@@ -466,7 +466,7 @@ | ||
466 | 466 | // XXX: %__lzcnt is not used now. |
467 | 467 | return details::floor_lb_w(x, size_t_<32>()); |
468 | 468 | } |
469 | -//@} | |
469 | +//!@} | |
470 | 470 | |
471 | 471 | } // namespace details; |
472 | 472 |
@@ -496,7 +496,7 @@ | ||
496 | 496 | |
497 | 497 | |
498 | 498 | //! \pre <tt>x != 0</tt> 。 |
499 | -//@{ | |
499 | +//!@{ | |
500 | 500 | //! \brief 同 ISO C++20 的 countl_zero ,但对参数为 0 时结果未定义。 |
501 | 501 | template<typename _type> |
502 | 502 | YB_ATTR_nodiscard YB_ATTR_always_inline YB_STATELESS yimpl(yconstfn) |
@@ -513,7 +513,7 @@ | ||
513 | 513 | { |
514 | 514 | return details::ctz(x); |
515 | 515 | } |
516 | -//@} | |
516 | +//!@} | |
517 | 517 | |
518 | 518 | inline namespace cpp2020 |
519 | 519 | { |
@@ -525,7 +525,7 @@ | ||
525 | 525 | 扩展可能实际支持在要求常量表达式的上下文中使用,但通常没有公开保证。 |
526 | 526 | 替代实现只支持至多 64 位整数。 |
527 | 527 | */ |
528 | -//@{ | |
528 | +//!@{ | |
529 | 529 | #if __cpp_lib_bitops >= 201907L |
530 | 530 | using std::countl_zero; |
531 | 531 | using std::countr_zero; |
@@ -546,7 +546,7 @@ | ||
546 | 546 | return x != 0 ? details::ctz(x) : std::numeric_limits<_type>::digits; |
547 | 547 | } |
548 | 548 | #endif |
549 | -//@} | |
549 | +//!@} | |
550 | 550 | |
551 | 551 | } // inline namespace cpp2020; |
552 | 552 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2011-2016, 2018-2019, 2021-2022 FrankHB. | |
2 | + © 2011-2016, 2018-2019, 2021-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file deref_op.hpp |
12 | 12 | \ingroup YStandardEx |
13 | 13 | \brief 解引用操作。 |
14 | -\version r265 | |
14 | +\version r278 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 576 |
17 | 17 | \par 创建时间: |
18 | 18 | 2015-02-10 13:12:26 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-11-28 19:53 +0800 | |
20 | + 2023-12-20 20:47 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -40,7 +40,7 @@ | ||
40 | 40 | \note 注意返回 \c false 不表示参数实际可解引用。 |
41 | 41 | \since build 461 |
42 | 42 | */ |
43 | -//@{ | |
43 | +//!@{ | |
44 | 44 | template<typename _tIter> |
45 | 45 | yconstfn bool |
46 | 46 | is_undereferenceable(const _tIter&) ynothrow |
@@ -53,7 +53,7 @@ | ||
53 | 53 | { |
54 | 54 | return !p; |
55 | 55 | } |
56 | -//@} | |
56 | +//!@} | |
57 | 57 | |
58 | 58 | |
59 | 59 | /*! |
@@ -68,9 +68,9 @@ | ||
68 | 68 | |
69 | 69 | |
70 | 70 | //! \since build 749 |
71 | -//@{ | |
71 | +//!@{ | |
72 | 72 | //! \brief 取非空引用或默认值。 |
73 | -//@{ | |
73 | +//!@{ | |
74 | 74 | template<typename _type> |
75 | 75 | yconstfn auto |
76 | 76 | nonnull_or(_type&& p) -> decay_t<decltype(yforward(p))> |
@@ -92,10 +92,10 @@ | ||
92 | 92 | { |
93 | 93 | return !bool(p == yforward(last)) ? yforward(p) : yforward(other); |
94 | 94 | } |
95 | -//@} | |
95 | +//!@} | |
96 | 96 | |
97 | 97 | //! \brief 调用非引用或默认值。 |
98 | -//@{ | |
98 | +//!@{ | |
99 | 99 | template<typename _type, typename _func> |
100 | 100 | yconstfn auto |
101 | 101 | call_nonnull_or(_func f, _type&& p) -> decay_t<decltype(f(yforward(p)))> |
@@ -118,11 +118,11 @@ | ||
118 | 118 | { |
119 | 119 | return !bool(p == yforward(last)) ? f(yforward(p)) : yforward(other); |
120 | 120 | } |
121 | -//@} | |
121 | +//!@} | |
122 | 122 | |
123 | 123 | |
124 | 124 | //! \brief 取非空值或默认值。 |
125 | -//@{ | |
125 | +//!@{ | |
126 | 126 | template<typename _type> |
127 | 127 | yconstfn auto |
128 | 128 | value_or(_type&& p) -> decay_t<decltype(*yforward(p))> |
@@ -143,10 +143,10 @@ | ||
143 | 143 | { |
144 | 144 | return !bool(p == yforward(last)) ? *yforward(p) : yforward(other); |
145 | 145 | } |
146 | -//@} | |
146 | +//!@} | |
147 | 147 | |
148 | 148 | //! \brief 调用非空值或取默认值。 |
149 | -//@{ | |
149 | +//!@{ | |
150 | 150 | template<typename _type, typename _func> |
151 | 151 | yconstfn auto |
152 | 152 | call_value_or(_func f, _type&& p) -> decay_t<decltype(f(*yforward(p)))> |
@@ -168,8 +168,8 @@ | ||
168 | 168 | { |
169 | 169 | return !bool(p == yforward(last)) ? f(*yforward(p)) : yforward(other); |
170 | 170 | } |
171 | -//@} | |
172 | -//@} | |
171 | +//!@} | |
172 | +//!@} | |
173 | 173 | |
174 | 174 | } // namespace ystdex; |
175 | 175 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2012-2013, 2015-2016, 2018-2022 FrankHB. | |
2 | + © 2012-2013, 2015-2016, 2018-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file examiner.hpp |
12 | 12 | \ingroup YStandardEx |
13 | 13 | \brief C++ 类型操作检测。 |
14 | -\version r148 | |
14 | +\version r150 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 348 |
17 | 17 | \par 创建时间: |
18 | 18 | 2012-10-17 01:21:01 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-02-04 16:13 +0800 | |
20 | + 2023-12-22 23:02 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -75,7 +75,7 @@ | ||
75 | 75 | { |
76 | 76 | //! \since build 675 |
77 | 77 | template<typename _type, typename _type2, yimpl(typename |
78 | - = enable_if_t<!has_equality_operator<_type&&, _type2&&>::value>)> | |
78 | + = enable_if_t<!has_equality_operator<_type, _type2>::value>)> | |
79 | 79 | YB_STATELESS static yconstfn bool |
80 | 80 | are_equal(_type&&, _type2&&) ynothrow |
81 | 81 | { |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2014-2018, 2020-2022 FrankHB. | |
2 | + © 2014-2018, 2020-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file exception.h |
12 | 12 | \ingroup YStandardEx |
13 | 13 | \brief 标准库异常扩展接口。 |
14 | -\version r341 | |
14 | +\version r352 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 522 |
17 | 17 | \par 创建时间: |
18 | 18 | 2014-07-25 20:14:51 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-10-07 20:21 +0800 | |
20 | + 2023-12-20 20:32 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -110,7 +110,7 @@ | ||
110 | 110 | \since build 475 |
111 | 111 | \ingroup exceptions |
112 | 112 | */ |
113 | -//@{ | |
113 | +//!@{ | |
114 | 114 | //! \brief 异常:不支持的操作。 |
115 | 115 | class YB_API unsupported : public std::logic_error |
116 | 116 | { |
@@ -167,11 +167,11 @@ | ||
167 | 167 | //! \brief 虚析构:类定义外默认实现。 |
168 | 168 | ~narrowing_error() override; |
169 | 169 | }; |
170 | -//@} | |
170 | +//!@} | |
171 | 171 | |
172 | 172 | |
173 | 173 | //! \since build 686 |
174 | -//@{ | |
174 | +//!@{ | |
175 | 175 | //! \brief 使用不满足构造限制检查导致的异常。 |
176 | 176 | class YB_API invalid_construction : public std::invalid_argument |
177 | 177 | { |
@@ -194,14 +194,14 @@ | ||
194 | 194 | */ |
195 | 195 | YB_NORETURN YB_API void |
196 | 196 | throw_invalid_construction(); |
197 | -//@} | |
197 | +//!@} | |
198 | 198 | |
199 | 199 | |
200 | 200 | //! \since build 848 |
201 | -//@{ | |
201 | +//!@{ | |
202 | 202 | /*! |
203 | 203 | \brief 不满足分配器兼容性要求导致的异常。 |
204 | -\sa alloc_rebind_t | |
204 | +\sa rebind_alloc_t | |
205 | 205 | \see WG21 P0043R0 。 |
206 | 206 | |
207 | 207 | 兼容的分配器可重绑定不同的类型进行分配。 |
@@ -230,15 +230,15 @@ | ||
230 | 230 | */ |
231 | 231 | YB_NORETURN YB_API void |
232 | 232 | throw_allocator_mismatch_error(); |
233 | -//@} | |
233 | +//!@} | |
234 | 234 | |
235 | 235 | |
236 | 236 | /*! |
237 | -\brief 抛出错误: std::system_error 或允许相同构造函数参数的异常。 | |
237 | +\brief 抛出错误:\c std::system_error 或允许相同构造函数参数的异常。 | |
238 | 238 | \throw _type 使用参数构造的异常。 |
239 | 239 | \since build 637 |
240 | 240 | */ |
241 | -//@{ | |
241 | +//!@{ | |
242 | 242 | template<class _type = std::system_error, typename... _tParams> |
243 | 243 | YB_NORETURN inline void |
244 | 244 | throw_error(std::error_code ec, _tParams&&... args) |
@@ -263,7 +263,7 @@ | ||
263 | 263 | { |
264 | 264 | throw _type(ev, ecat, yforward(args)...); |
265 | 265 | } |
266 | -//@} | |
266 | +//!@} | |
267 | 267 | |
268 | 268 | } // namespace ystdex; |
269 | 269 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2012, 2016, 2018, 2020-2022 FrankHB. | |
2 | + © 2012, 2016, 2018, 2020-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file function_adaptor.hpp |
12 | 12 | \ingroup YStandardEx |
13 | 13 | \brief 函数适配器。 |
14 | -\version r5130 | |
14 | +\version r5161 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 939 |
17 | 17 | \par 创建时间: |
18 | 18 | 2022-02-14 06:37:03 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-02-15 18:04 +0800 | |
20 | + 2023-12-20 21:58 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -41,7 +41,7 @@ | ||
41 | 41 | \brief 更新间接调用对象。 |
42 | 42 | \note 可配合跳板实现异步调用。 |
43 | 43 | */ |
44 | -//@{ | |
44 | +//!@{ | |
45 | 45 | //! \since build 881 |
46 | 46 | template<class _tThunk, typename _func> |
47 | 47 | inline void |
@@ -55,7 +55,7 @@ | ||
55 | 55 | }, std::move(thunk), yforward(f)); |
56 | 56 | } |
57 | 57 | //! \since build 928 |
58 | -//@{ | |
58 | +//!@{ | |
59 | 59 | template<class _tThunk, typename _func> |
60 | 60 | inline void |
61 | 61 | update_thunk(_tThunk& thunk, trivial_swap_t, _func&& f) |
@@ -92,8 +92,8 @@ | ||
92 | 92 | cur(); |
93 | 93 | }, std::move(thunk), yforward(f))); |
94 | 94 | } |
95 | -//@} | |
96 | -//@} | |
95 | +//!@} | |
96 | +//!@} | |
97 | 97 | |
98 | 98 | |
99 | 99 | /*! |
@@ -105,23 +105,22 @@ | ||
105 | 105 | \todo 复用静态断言。 |
106 | 106 | \todo 简化转移实现。 |
107 | 107 | */ |
108 | -//@{ | |
109 | -template<typename _func, typename _tRes = void, typename _tState = bool> | |
108 | +//!@{ | |
109 | +template<typename _func, typename _tRes = void, typename _tCond = bool> | |
110 | 110 | struct one_shot |
111 | 111 | { |
112 | 112 | static_assert(is_nothrow_move_constructible<_func>(), |
113 | 113 | "Invalid target type found."); |
114 | 114 | static_assert(is_nothrow_move_constructible<_tRes>(), |
115 | 115 | "Invalid result type found."); |
116 | - static_assert(is_nothrow_swappable<_tState>(), | |
117 | - "Invalid state type found."); | |
116 | + static_assert(is_nothrow_swappable<_tCond>(), "Invalid state type found."); | |
118 | 117 | |
119 | 118 | _func func; |
120 | 119 | mutable _tRes result; |
121 | - mutable _tState fresh{}; | |
120 | + mutable _tCond fresh{}; | |
122 | 121 | |
123 | 122 | //! \since build 820 |
124 | - template<typename _type, typename _type2 = _tState, | |
123 | + template<typename _type, typename _type2 = _tCond, | |
125 | 124 | yimpl(typename = exclude_self_t<one_shot, _type>)> |
126 | 125 | one_shot(_type&& f, _tRes r = {}, _type2&& s = {}) |
127 | 126 | : func(yforward(f)), result(r), fresh(yforward(s)) |
@@ -142,8 +141,7 @@ | ||
142 | 141 | |
143 | 142 | template<typename... _tParams> |
144 | 143 | yconstfn_relaxed auto |
145 | - operator()(_tParams&&... args) const | |
146 | - ynoexcept(noexcept(func(yforward(args)...))) | |
144 | + operator()(_tParams&&... args) const ynoexcept_spec(func(yforward(args)...)) | |
147 | 145 | -> decltype(func(yforward(args)...)) |
148 | 146 | { |
149 | 147 | if(fresh) |
@@ -155,19 +153,19 @@ | ||
155 | 153 | } |
156 | 154 | }; |
157 | 155 | |
158 | -template<typename _func, typename _tState> | |
159 | -struct one_shot<_func, void, _tState> | |
156 | +template<typename _func, typename _tCond> | |
157 | +struct one_shot<_func, void, _tCond> | |
160 | 158 | { |
161 | 159 | static_assert(is_nothrow_move_constructible<_func>(), |
162 | 160 | "Invalid target type found."); |
163 | - static_assert(is_nothrow_swappable<_tState>(), | |
161 | + static_assert(is_nothrow_swappable<_tCond>(), | |
164 | 162 | "Invalid state type found."); |
165 | 163 | |
166 | 164 | _func func; |
167 | - mutable _tState fresh{}; | |
165 | + mutable _tCond fresh{}; | |
168 | 166 | |
169 | 167 | //! \since build 820 |
170 | - template<typename _type, typename _type2 = _tState, | |
168 | + template<typename _type, typename _type2 = _tCond, | |
171 | 169 | yimpl(typename = exclude_self_t<one_shot, _type>)> |
172 | 170 | one_shot(_type&& f, _type2&& s = {}) |
173 | 171 | : func(yforward(f)), fresh(yforward(s)) |
@@ -188,8 +186,7 @@ | ||
188 | 186 | |
189 | 187 | template<typename... _tParams> |
190 | 188 | yconstfn_relaxed void |
191 | - operator()(_tParams&&... args) const | |
192 | - ynoexcept(noexcept(func(yforward(args)...))) | |
189 | + operator()(_tParams&&... args) const ynoexcept_spec(func(yforward(args)...)) | |
193 | 190 | { |
194 | 191 | if(fresh) |
195 | 192 | { |
@@ -216,8 +213,7 @@ | ||
216 | 213 | |
217 | 214 | template<typename... _tParams> |
218 | 215 | yconstfn_relaxed auto |
219 | - operator()(_tParams&&... args) const | |
220 | - ynoexcept(noexcept(func(yforward(args)...))) | |
216 | + operator()(_tParams&&... args) const ynoexcept_spec(func(yforward(args)...)) | |
221 | 217 | -> decltype(func(yforward(args)...) && noexcept(func = {})) |
222 | 218 | { |
223 | 219 | if(func) |
@@ -253,29 +249,29 @@ | ||
253 | 249 | } |
254 | 250 | } |
255 | 251 | }; |
256 | -//@} | |
252 | +//!@} | |
257 | 253 | |
258 | 254 | /*! |
259 | 255 | \relates one_shot |
260 | 256 | \since build 926 |
261 | 257 | */ |
262 | -//@{ | |
263 | -template<typename _func, typename _tRes, typename _tState> | |
264 | -struct is_bitwise_swappable<one_shot<_func, _tRes, _tState>> | |
258 | +//!@{ | |
259 | +template<typename _func, typename _tRes, typename _tCond> | |
260 | +struct is_bitwise_swappable<one_shot<_func, _tRes, _tCond>> | |
265 | 261 | : and_<is_bitwise_swappable<_func>, is_bitwise_swappable<_tRes>, |
266 | - is_bitwise_swappable<_tState>> | |
262 | + is_bitwise_swappable<_tCond>> | |
267 | 263 | {}; |
268 | 264 | |
269 | -template<typename _func, typename _tState> | |
270 | -struct is_bitwise_swappable<one_shot<_func, void, _tState>> | |
271 | - : and_<is_bitwise_swappable<_func>, is_bitwise_swappable<_tState>> | |
265 | +template<typename _func, typename _tCond> | |
266 | +struct is_bitwise_swappable<one_shot<_func, void, _tCond>> | |
267 | + : and_<is_bitwise_swappable<_func>, is_bitwise_swappable<_tCond>> | |
272 | 268 | {}; |
273 | 269 | |
274 | 270 | template<typename _func, typename _tRes> |
275 | 271 | struct is_bitwise_swappable<one_shot<_func, _tRes, void>> |
276 | 272 | : and_<is_bitwise_swappable<_func>, is_bitwise_swappable<_tRes>> |
277 | 273 | {}; |
278 | -//@} | |
274 | +//!@} | |
279 | 275 | |
280 | 276 | } // namespace ystdex; |
281 | 277 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2010-2022 FrankHB. | |
2 | + © 2010-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file functional.hpp |
12 | 12 | \ingroup YStandardEx |
13 | 13 | \brief 函数和可调用对象。 |
14 | -\version r5335 | |
14 | +\version r5418 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 333 |
17 | 17 | \par 创建时间: |
18 | 18 | 2010-08-22 13:04:29 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-02-15 06:36 +0800 | |
20 | + 2023-12-23 15:28 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -29,13 +29,104 @@ | ||
29 | 29 | #define YB_INC_ystdex_functional_hpp_ 1 |
30 | 30 | |
31 | 31 | #include "function_adaptor.hpp" // for "invoke.hpp", "ref.hpp", "functor.hpp", |
32 | -// "bind.hpp", "compose.hpp", "function_adaptor.hpp", <functional>; | |
32 | +// "bind.hpp", "compose.hpp", "function_adaptor.hpp", <functional>, | |
33 | +// exclude_self_t, std::declval, invoke_result_t, is_nothrow_invocable, | |
34 | +// ystdex::invoke, std::forward, is_nothrow_constructible; | |
33 | 35 | #include "expanded_function.hpp" // for "function.hpp", "expanded_function.hpp"; |
34 | 36 | #include "hash.hpp" // for "hash.hpp"; |
35 | 37 | |
38 | +/*! | |
39 | +\brief \c \<functional> 特性测试宏。 | |
40 | +\see ISO C++20 [version.syn] 。 | |
41 | +\see WG21 P0005R4 。 | |
42 | +\see WG21 P0358R1 。 | |
43 | +\see WG21 P0941R2 2.2 。 | |
44 | +\see https://docs.microsoft.com/cpp/visual-cpp-language-conformance 。 | |
45 | +\see https://docs.microsoft.com/cpp/preprocessor/predefined-macros 。 | |
46 | +\see https://blogs.msdn.microsoft.com/vcblog/2016/10/11/c1417-features-and-stl-fixes-in-vs-15-preview-5/ 。 | |
47 | +\since build 982 | |
48 | +*/ | |
49 | +//!@{ | |
50 | +#ifndef __cpp_lib_not_fn | |
51 | +# if (YB_IMPL_MSCPP >= 1920 && _MSVC_LANG >= 201603L) \ | |
52 | + || __cplusplus >= 201703L | |
53 | +# define __cpp_lib_not_fn 201603L | |
54 | +# endif | |
55 | +#endif | |
56 | +//!@} | |
57 | + | |
36 | 58 | namespace ystdex |
37 | 59 | { |
38 | 60 | |
61 | +//! \since build 982 | |
62 | +//!@{ | |
63 | +//! \warning 非虚析构。 | |
64 | +template<typename _func> | |
65 | +class not_fn_t | |
66 | +{ | |
67 | +private: | |
68 | + _func fn; | |
69 | + | |
70 | +public: | |
71 | + template<typename _tParam, | |
72 | + yimpl(typename = exclude_self_t<not_fn_t, _tParam>)> | |
73 | + yconstfn | |
74 | + not_fn_t(_tParam&& arg) | |
75 | + : fn(yforward(arg)) | |
76 | + {} | |
77 | + not_fn_t(const not_fn_t&) = default; | |
78 | + not_fn_t(not_fn_t&&) = default; | |
79 | + | |
80 | +private: | |
81 | + template<typename _type> | |
82 | + static decltype(!std::declval<_type>()) | |
83 | + neg() ynoexcept_spec(!std::declval<_type>()); | |
84 | + | |
85 | +#define YB_Impl_functional_not_fn_op(_q) \ | |
86 | + template<typename... _tParams> \ | |
87 | + decltype(neg<invoke_result_t<_func _q, _tParams...>>()) \ | |
88 | + operator()(_tParams&&... args) _q \ | |
89 | + ynoexcept(is_nothrow_invocable<_func _q, _tParams...>() \ | |
90 | + && noexcept(neg<invoke_result_t<_func _q, _tParams...>>())) \ | |
91 | + { \ | |
92 | + return !ystdex::invoke(std::forward<_func _q>(fn), yforward(args)...); \ | |
93 | + } | |
94 | + | |
95 | + YB_Impl_functional_not_fn_op(&) | |
96 | + YB_Impl_functional_not_fn_op(const&) | |
97 | + YB_Impl_functional_not_fn_op(&&) | |
98 | + YB_Impl_functional_not_fn_op(const&&) | |
99 | +#undef YB_Impl_functional_not_fn_op | |
100 | +}; | |
101 | + | |
102 | + | |
103 | +/*! | |
104 | +\see ISO C++17 [func.not.fn] 。 | |
105 | +\see WG21 P0005R4 。 | |
106 | +\see WG21 P0358R1 。 | |
107 | +\see LWG 2767 。 | |
108 | +*/ | |
109 | +//!@{ | |
110 | +inline namespace cpp2017 | |
111 | +{ | |
112 | + | |
113 | +#if __cpp_lib_not_fn >= 201603L | |
114 | +using std::not_fn; | |
115 | +#else | |
116 | +//! ingroup YBase_replacement_features | |
117 | +template<typename _func> | |
118 | +inline auto | |
119 | +not_fn(_func&& f) ynoexcept(is_nothrow_constructible<decay_t<_func>, _func>()) | |
120 | + -> decltype(yimpl(not_fn_t)<decay_t<_func>>(yforward(f))) | |
121 | +{ | |
122 | + return yimpl(not_fn_t)<decay_t<_func>>(yforward(f)); | |
123 | +} | |
124 | +#endif | |
125 | + | |
126 | +} // inline namespace cpp2017; | |
127 | +//!@} | |
128 | +//!@} | |
129 | + | |
39 | 130 | } // namespace ystdex; |
40 | 131 | |
41 | 132 | #endif |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2015-2016, 2018-2022 FrankHB. | |
2 | + © 2015-2016, 2018-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file placement.hpp |
12 | 12 | \ingroup YStandardEx |
13 | 13 | \brief 放置对象管理操作。 |
14 | -\version r1185 | |
14 | +\version r1192 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 715 |
17 | 17 | \par 创建时间: |
18 | 18 | 2016-08-03 18:56:31 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-09-07 08:48 +0800 | |
20 | + 2023-12-23 15:35 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -321,7 +321,6 @@ | ||
321 | 321 | |
322 | 322 | |
323 | 323 | /*! |
324 | -\tparam _type 构造的对象类型。 | |
325 | 324 | \param obj 构造的存储对象。 |
326 | 325 | \since build 716 |
327 | 326 | */ |
@@ -356,10 +355,10 @@ | ||
356 | 355 | } |
357 | 356 | //!@} |
358 | 357 | |
358 | +//! \param obj 构造的存储对象。 | |
359 | +//!@{ | |
359 | 360 | /*! |
360 | 361 | \brief 以默认初始化原地构造。 |
361 | -\tparam _tParams 用于构造对象的参数包类型。 | |
362 | -\param args 用于构造对象的参数包。 | |
363 | 362 | \since build 716 |
364 | 363 | */ |
365 | 364 | template<typename _type> |
@@ -381,6 +380,7 @@ | ||
381 | 380 | { |
382 | 381 | yunused(ystdex::construct_within<_type>(obj, yforward(args)...)); |
383 | 382 | } |
383 | +//!@} | |
384 | 384 | |
385 | 385 | //! \since build 602 |
386 | 386 | //!@{ |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2015-2016, 2018-2022 FrankHB. | |
2 | + © 2015-2016, 2018-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file range.hpp |
12 | 12 | \ingroup YStandardEx |
13 | 13 | \brief 范围操作。 |
14 | -\version r1233 | |
14 | +\version r1262 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 624 |
17 | 17 | \par 创建时间: |
18 | 18 | 2015-08-18 22:33:54 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-11-21 01:13 +0800 | |
20 | + 2023-12-20 20:52 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -41,45 +41,45 @@ | ||
41 | 41 | \see ISO C++20 [version.syn] 。 |
42 | 42 | \see WG21 P0941R2 2.2 。 |
43 | 43 | */ |
44 | -//@{ | |
44 | +//!@{ | |
45 | 45 | /*! |
46 | 46 | \see WG21 P0031R0 。 |
47 | 47 | \see https://docs.microsoft.com/cpp/preprocessor/predefined-macros 。 |
48 | 48 | \since build 834 |
49 | 49 | */ |
50 | -//@{ | |
50 | +//!@{ | |
51 | 51 | #ifndef __cpp_lib_array_constexpr |
52 | 52 | # if (YB_IMPL_MSCPP >= 1911 && _MSVC_LANG >= 201603L) \ |
53 | 53 | || __cplusplus >= 201603L |
54 | 54 | # define __cpp_lib_array_constexpr 201603L |
55 | 55 | # endif |
56 | 56 | #endif |
57 | -//@} | |
57 | +//!@} | |
58 | 58 | /*! |
59 | 59 | \see LWG 2285 。 |
60 | 60 | \see https://blogs.msdn.microsoft.com/vcblog/2016/01/22/vs-2015-update-2s-stl-is-c17-so-far-feature-complete/ 。 |
61 | 61 | \since build 832 |
62 | 62 | */ |
63 | -//@{ | |
63 | +//!@{ | |
64 | 64 | #ifndef __cpp_lib_make_reverse_iterator |
65 | 65 | # if YB_IMPL_MSCPP >= 1800 || __cplusplus >= 201402L |
66 | 66 | # define __cpp_lib_make_reverse_iterator 201210L |
67 | 67 | # endif |
68 | 68 | #endif |
69 | -//@} | |
69 | +//!@} | |
70 | 70 | /*! |
71 | 71 | \see WG21 N4280 。 |
72 | 72 | \see https://docs.microsoft.com/cpp/visual-cpp-language-conformance 。 |
73 | 73 | \since build 834 |
74 | 74 | */ |
75 | -//@{ | |
75 | +//!@{ | |
76 | 76 | #ifndef __cpp_lib_nonmember_container_access |
77 | 77 | # if YB_IMPL_MSCPP >= 1800 || __cplusplus >= 201411L |
78 | 78 | # define __cpp_lib_nonmember_container_access 201411L |
79 | 79 | # endif |
80 | 80 | #endif |
81 | -//@} | |
82 | -//@} | |
81 | +//!@} | |
82 | +//!@} | |
83 | 83 | |
84 | 84 | namespace ystdex |
85 | 85 | { |
@@ -251,7 +251,7 @@ | ||
251 | 251 | \since build 834 |
252 | 252 | \see LWG 280 。 |
253 | 253 | */ |
254 | - //@{ | |
254 | + //!@{ | |
255 | 255 | template<typename _tIter2> |
256 | 256 | YB_ATTR_nodiscard YB_PURE friend yconstfn bool |
257 | 257 | operator==(const reverse_iterator& x, const reverse_iterator<_tIter2>& y) |
@@ -293,7 +293,7 @@ | ||
293 | 293 | { |
294 | 294 | return x.current >= y.current; |
295 | 295 | } |
296 | - //@} | |
296 | + //!@} | |
297 | 297 | |
298 | 298 | YB_ATTR_nodiscard YB_PURE friend yconstfn reverse_iterator |
299 | 299 | operator+(difference_type n, const reverse_iterator& x) |
@@ -379,7 +379,7 @@ | ||
379 | 379 | \ingroup YBase_replacement_features |
380 | 380 | \since build 833 |
381 | 381 | */ |
382 | -//@{ | |
382 | +//!@{ | |
383 | 383 | //! \since build 664 |
384 | 384 | template<typename _type, size_t _vN> |
385 | 385 | YB_ATTR_nodiscard YB_PURE yconstfn _type* |
@@ -409,14 +409,14 @@ | ||
409 | 409 | { |
410 | 410 | return reverse_iterator<_type*>(array); |
411 | 411 | } |
412 | -//@} | |
412 | +//!@} | |
413 | 413 | |
414 | 414 | //! \since build 834 |
415 | 415 | inline namespace cpp2017 |
416 | 416 | { |
417 | 417 | |
418 | 418 | //! \since build 624 |
419 | -//@{ | |
419 | +//!@{ | |
420 | 420 | // XXX: To prevent introduce non-'constexpr' version of %std::(begin, end), |
421 | 421 | // %__cpp_lib_array_constexpr is also checked, even the direct interface is not |
422 | 422 | // changed from the original version in ISO C++14. |
@@ -433,7 +433,7 @@ | ||
433 | 433 | using std::crend; |
434 | 434 | #else |
435 | 435 | //! \since build 938 |
436 | -//@{ | |
436 | +//!@{ | |
437 | 437 | template<typename _tRange, YB_Impl_Range_DisambiguousParams> |
438 | 438 | YB_ATTR_nodiscard YB_PURE yconstfn auto |
439 | 439 | cbegin(const _tRange& c, YB_Impl_Range_DisambiguousArgs) |
@@ -462,7 +462,7 @@ | ||
462 | 462 | { |
463 | 463 | return c.rbegin(); |
464 | 464 | } |
465 | -//@} | |
465 | +//!@} | |
466 | 466 | //! \since build 833 |
467 | 467 | template<typename _type, size_t _vN> |
468 | 468 | YB_ATTR_nodiscard YB_PURE yconstfn reverse_iterator<_type*> |
@@ -510,7 +510,8 @@ | ||
510 | 510 | //! \since build 938 |
511 | 511 | template<typename _tRange, YB_Impl_Range_DisambiguousParams> |
512 | 512 | YB_ATTR_nodiscard YB_PURE yconstfn auto |
513 | -crbegin(const _tRange& c, YB_Impl_Range_DisambiguousArgs) -> decltype(ystdex::rbegin(c)) | |
513 | +crbegin(const _tRange& c, YB_Impl_Range_DisambiguousArgs) | |
514 | + -> decltype(ystdex::rbegin(c)) | |
514 | 515 | { |
515 | 516 | return ystdex::rbegin(c); |
516 | 517 | } |
@@ -518,12 +519,13 @@ | ||
518 | 519 | //! \since build 938 |
519 | 520 | template<typename _tRange, YB_Impl_Range_DisambiguousParams> |
520 | 521 | YB_ATTR_nodiscard YB_PURE yconstfn auto |
521 | -crend(const _tRange& c, YB_Impl_Range_DisambiguousArgs) -> decltype(ystdex::rend(c)) | |
522 | +crend(const _tRange& c, YB_Impl_Range_DisambiguousArgs) | |
523 | + -> decltype(ystdex::rend(c)) | |
522 | 524 | { |
523 | 525 | return ystdex::rend(c); |
524 | 526 | } |
525 | 527 | #endif |
526 | -//@} | |
528 | +//!@} | |
527 | 529 | |
528 | 530 | #undef YB_Impl_Range_DisambiguousArgs |
529 | 531 | #undef YB_Impl_Range_DisambiguousParams |
@@ -543,7 +545,7 @@ | ||
543 | 545 | 所以不能帮助推导需要常量访问初值符列表的情形。 |
544 | 546 | 因此,在此提供扩展,以允许和其它方式相同的方式直接以初值符调用这些访问函数模板。 |
545 | 547 | */ |
546 | -//@{ | |
548 | +//!@{ | |
547 | 549 | template<typename _tElem> |
548 | 550 | YB_ATTR_nodiscard YB_PURE yconstfn const _tElem* |
549 | 551 | cbegin(std::initializer_list<_tElem> il) ynothrow |
@@ -573,7 +575,7 @@ | ||
573 | 575 | { |
574 | 576 | return ystdex::rend(il); |
575 | 577 | } |
576 | -//@} | |
578 | +//!@} | |
577 | 579 | |
578 | 580 | /*! |
579 | 581 | \brief 类容器访问。 |
@@ -581,7 +583,7 @@ | ||
581 | 583 | \see ISO C++17 [iterator.container] 。 |
582 | 584 | \since build 663 |
583 | 585 | */ |
584 | -//@{ | |
586 | +//!@{ | |
585 | 587 | //! \since build 834 |
586 | 588 | inline namespace cpp2017 |
587 | 589 | { |
@@ -667,20 +669,20 @@ | ||
667 | 669 | { |
668 | 670 | return array; |
669 | 671 | } |
670 | -//@} | |
672 | +//!@} | |
671 | 673 | |
672 | 674 | /*! |
673 | 675 | \ingroup metafunctions |
674 | 676 | \since build 899 |
675 | 677 | */ |
676 | -//@{ | |
678 | +//!@{ | |
677 | 679 | template<typename _tRange> |
678 | 680 | using range_iterator_t = decltype(ystdex::begin(std::declval<_tRange&>())); |
679 | 681 | |
680 | 682 | template<typename _tRange> |
681 | 683 | using range_const_iterator_t |
682 | 684 | = decltype(ystdex::cbegin(std::declval<const _tRange&>())); |
683 | -//@} | |
685 | +//!@} | |
684 | 686 | |
685 | 687 | //! \since build 546 |
686 | 688 | namespace details |
@@ -720,7 +722,7 @@ | ||
720 | 722 | 若可调用结果可转换为 size_t 的 ADL 函数 size 则使用 ADL size ; |
721 | 723 | 否则使用 std::distance 计算范围迭代器确定范围大小。 |
722 | 724 | */ |
723 | -//@{ | |
725 | +//!@{ | |
724 | 726 | template<typename _tRange> |
725 | 727 | yconstfn auto |
726 | 728 | range_size(const _tRange& c) |
@@ -734,7 +736,7 @@ | ||
734 | 736 | { |
735 | 737 | return size(il); |
736 | 738 | } |
737 | -//@} | |
739 | +//!@} | |
738 | 740 | |
739 | 741 | } // namespace ystdex; |
740 | 742 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2011-2017, 2019, 2021-2022 FrankHB. | |
2 | + © 2011-2017, 2019, 2021-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file rational.hpp |
12 | 12 | \ingroup YStandardEx |
13 | 13 | \brief 有理数运算。 |
14 | -\version r2267 | |
14 | +\version r2308 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 260 |
17 | 17 | \par 创建时间: |
18 | 18 | 2011-11-12 23:23:47 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-01-21 20:45 +0805 | |
20 | + 2023-12-20 20:36 +0805 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -38,11 +38,11 @@ | ||
38 | 38 | { |
39 | 39 | |
40 | 40 | //! \since build 588 |
41 | -//@{ | |
41 | +//!@{ | |
42 | 42 | //! \brief 判断指定的值是否为零值。 |
43 | -//@{ | |
43 | +//!@{ | |
44 | 44 | template<typename _type> |
45 | -yconstfn yimpl(enable_if_t)<is_floating_point<_type>::value, bool> | |
45 | +yconstfn yimpl(enable_if_t)<is_floating_point<_type>{}, bool> | |
46 | 46 | is_zero(_type x) |
47 | 47 | { |
48 | 48 | return std::fpclassify(x) == FP_ZERO; |
@@ -54,7 +54,7 @@ | ||
54 | 54 | { |
55 | 55 | return x == _type(0); |
56 | 56 | } |
57 | -//@} | |
57 | +//!@} | |
58 | 58 | |
59 | 59 | |
60 | 60 | /*! |
@@ -62,7 +62,7 @@ | ||
62 | 62 | \pre 参数为有限值。 |
63 | 63 | \warning 不检查参数。 |
64 | 64 | */ |
65 | -//@{ | |
65 | +//!@{ | |
66 | 66 | /*! |
67 | 67 | \note 不检查误差非零。 |
68 | 68 | \note 使用 ADL round 。 |
@@ -82,7 +82,7 @@ | ||
82 | 82 | { |
83 | 83 | return ystdex::is_zero(err) ? x : ystdex::round_in_nocheck(x, err); |
84 | 84 | } |
85 | -//@} | |
85 | +//!@} | |
86 | 86 | |
87 | 87 | |
88 | 88 | //! \brief 计算整数次幂。 |
@@ -117,7 +117,7 @@ | ||
117 | 117 | { |
118 | 118 | return ystdex::square(ystdex::square(x)); |
119 | 119 | } |
120 | -//@} | |
120 | +//!@} | |
121 | 121 | |
122 | 122 | |
123 | 123 | /*! |
@@ -145,12 +145,12 @@ | ||
145 | 145 | |
146 | 146 | 基于整数算术实现的确定有限精度二进制定点小数类型。可用于替换内建的浮点数类型。 |
147 | 147 | 是否有符号同基本整数类型参数。若有符号,则最高有效位为符号位。 |
148 | -逻辑布局: [符号位]|整数部分|小数部分 。各个部分的内部为补码表示。 | |
148 | +逻辑布局:[符号位]|整数部分|小数部分 。各个部分的内部为补码表示。 | |
149 | 149 | \tparam _tBase 基本整数类型。 |
150 | 150 | \tparam _vInt 整数部分(若有符号则不包括符号位,下同)二进制位数。 |
151 | 151 | \tparam _vFrac 分数部分二进制位数。 |
152 | 152 | \note 默认保留 6 位二进制小数。 |
153 | -\note 部分实现参考: http://www.codeproject.com/KB/cpp/fp_math.aspx 。 | |
153 | +\note 部分实现参考:http://www.codeproject.com/KB/cpp/fp_math.aspx 。 | |
154 | 154 | \warning 基本整数类型需要具有补码表示。 |
155 | 155 | \warning 非虚析构。 |
156 | 156 | \warning 算术运算可能溢出。 |
@@ -201,36 +201,36 @@ | ||
201 | 201 | template<typename _tInt> |
202 | 202 | yconstfn |
203 | 203 | fixed_point(_tInt val, |
204 | - yimpl(enable_if_t<is_integral<_tInt>::value, _tInt*> = {})) ynothrowv | |
204 | + yimpl(enable_if_t<is_integral<_tInt>{}, _tInt*> = {})) ynothrowv | |
205 | 205 | // XXX: Conversion to 'base_type' might be implementation-defined if |
206 | 206 | // it is signed. |
207 | 207 | : value(base_type(val << frac_bit_n)) |
208 | 208 | {} |
209 | 209 | //! \since build 581 |
210 | - //@{ | |
210 | + //!@{ | |
211 | 211 | template<typename _tFloat> |
212 | 212 | explicit yconstfn |
213 | - fixed_point(_tFloat val, yimpl(enable_if_t< | |
214 | - is_floating_point<_tFloat>::value, _tFloat*> = {})) ynothrow | |
213 | + fixed_point(_tFloat val, yimpl( | |
214 | + enable_if_t<is_floating_point<_tFloat>{}, _tFloat*> = {})) ynothrow | |
215 | 215 | : value(base_type(std::llround(base_element() * val))) |
216 | 216 | {} |
217 | 217 | template<typename _tFirst, typename _tSecond> |
218 | 218 | //! \since build 595 |
219 | - //@{ | |
219 | + //!@{ | |
220 | 220 | yconstfn |
221 | 221 | fixed_point(_tFirst x, _tSecond y, yimpl(enable_if_t<and_<is_integral< |
222 | - _tFirst>, not_<is_same<_tSecond, raw_tag>>>::value, _tFirst*> = {})) | |
222 | + _tFirst>, not_<is_same<_tSecond, raw_tag>>>{}, _tFirst*> = {})) | |
223 | 223 | ynothrowv |
224 | 224 | : value((x << frac_bit_n) / y) |
225 | 225 | {} |
226 | 226 | template<typename _tFirst, typename _tSecond> |
227 | 227 | explicit yconstfn |
228 | 228 | fixed_point(_tFirst x, _tSecond y, yimpl(enable_if_t<and_<is_floating_point< |
229 | - _tFirst>, not_<is_same<_tSecond, raw_tag>>>::value, _tFirst*> = {})) | |
229 | + _tFirst>, not_<is_same<_tSecond, raw_tag>>>{}, _tFirst*> = {})) | |
230 | 230 | ynothrowv |
231 | 231 | : fixed_point(x / y) |
232 | 232 | {} |
233 | - //@} | |
233 | + //!@} | |
234 | 234 | //! \since build 260 |
235 | 235 | yconstfn |
236 | 236 | fixed_point(const fixed_point&) = default; |
@@ -267,7 +267,7 @@ | ||
267 | 267 | ynothrow |
268 | 268 | : value(f.value << (frac_bit_n - _vOtherFrac)) |
269 | 269 | {} |
270 | - //@} | |
270 | + //!@} | |
271 | 271 | |
272 | 272 | //! \since build 586 |
273 | 273 | fixed_point& |
@@ -316,7 +316,7 @@ | ||
316 | 316 | } |
317 | 317 | |
318 | 318 | //! \since build 595 |
319 | - //@{ | |
319 | + //!@{ | |
320 | 320 | fixed_point& |
321 | 321 | operator++() ynothrowv |
322 | 322 | { |
@@ -348,7 +348,7 @@ | ||
348 | 348 | fixed_point& |
349 | 349 | operator*=(const fixed_point& f) ynothrowv |
350 | 350 | { |
351 | - value = mul<frac_bit_n + is_signed<base_type>::value>(value, | |
351 | + value = mul<frac_bit_n + is_signed<base_type>()>(value, | |
352 | 352 | f.value, is_signed<typename make_widen_int<base_type>::type>()); |
353 | 353 | return *this; |
354 | 354 | } |
@@ -362,7 +362,7 @@ | ||
362 | 362 | / f.value); |
363 | 363 | return *this; |
364 | 364 | } |
365 | - //@} | |
365 | + //!@} | |
366 | 366 | |
367 | 367 | fixed_point& |
368 | 368 | operator>>=(size_t s) ynothrow |
@@ -380,22 +380,22 @@ | ||
380 | 380 | } |
381 | 381 | |
382 | 382 | //! \since build 581 |
383 | - //@{ | |
383 | + //!@{ | |
384 | 384 | template<typename _type, |
385 | - yimpl(typename = enable_if_t<is_integral<_type>::value>)> | |
385 | + yimpl(typename = enable_if_t<is_integral<_type>{}>)> | |
386 | 386 | explicit yconstfn |
387 | 387 | operator _type() const ynothrow |
388 | 388 | { |
389 | 389 | return _type(value >> base_type(frac_bit_n)); |
390 | 390 | } |
391 | 391 | template<typename _type, yimpl(typename _type2 = _type, |
392 | - typename = enable_if_t<is_floating_point<_type2>::value>)> | |
392 | + typename = enable_if_t<is_floating_point<_type2>{}>)> | |
393 | 393 | yconstfn |
394 | 394 | operator _type() const ynothrow |
395 | 395 | { |
396 | 396 | return _type(value) / base_element(); |
397 | 397 | } |
398 | - //@} | |
398 | + //!@} | |
399 | 399 | |
400 | 400 | //! \since build 717 |
401 | 401 | friend yconstfn fixed_point |
@@ -513,7 +513,7 @@ | ||
513 | 513 | // because name lookup cannot find both in-class and out-of-class declarations |
514 | 514 | // without ambiguity. |
515 | 515 | //! \relates fixed_point |
516 | -//@{ | |
516 | +//!@{ | |
517 | 517 | #define YB_Impl_Rational_fp_TmplHead_2 \ |
518 | 518 | template<YB_Impl_Rational_fp_PList1, YB_Impl_Rational_fp_PList2> |
519 | 519 | #define YB_Impl_Rational_fp_TmplHead_2_l \ |
@@ -539,7 +539,7 @@ | ||
539 | 539 | \brief 不同模板参数的二元算术操作符。 |
540 | 540 | \since build 439 |
541 | 541 | */ |
542 | -//@{ | |
542 | +//!@{ | |
543 | 543 | #define YB_Impl_Rational_fp_arithmetic2(_op) \ |
544 | 544 | YB_Impl_Rational_fp_TmplHead_2 \ |
545 | 545 | yconstfn common_type_t<YB_Impl_Rational_fp_T1, YB_Impl_Rational_fp_T2> \ |
@@ -547,13 +547,13 @@ | ||
547 | 547 | YB_Impl_Rational_fp_TmplBody_Impl_2(_op) \ |
548 | 548 | \ |
549 | 549 | YB_Impl_Rational_fp_TmplHead_2_l \ |
550 | - yconstfn enable_if_t<is_arithmetic<_type>::value, \ | |
550 | + yconstfn enable_if_t<is_arithmetic<_type>{}, \ | |
551 | 551 | common_type_t<YB_Impl_Rational_fp_T, _type>> \ |
552 | 552 | YB_Impl_Rational_fp_TmplSig_2_l(_op) \ |
553 | 553 | YB_Impl_Rational_fp_TmplBody_Impl_2(_op) \ |
554 | 554 | \ |
555 | 555 | YB_Impl_Rational_fp_TmplHead_2_r \ |
556 | - yconstfn enable_if_t<is_arithmetic<_type>::value, \ | |
556 | + yconstfn enable_if_t<is_arithmetic<_type>{}, \ | |
557 | 557 | common_type_t<_type, YB_Impl_Rational_fp_T>> \ |
558 | 558 | YB_Impl_Rational_fp_TmplSig_2_r(_op) \ |
559 | 559 | YB_Impl_Rational_fp_TmplBody_Impl_2(_op) |
@@ -564,13 +564,13 @@ | ||
564 | 564 | YB_Impl_Rational_fp_arithmetic2(/) |
565 | 565 | |
566 | 566 | #undef YB_Impl_Rational_fp_ar2 |
567 | -//@} | |
567 | +//!@} | |
568 | 568 | |
569 | 569 | /*! |
570 | 570 | \brief 不同模板参数的二元关系操作符。 |
571 | 571 | \since build 440 |
572 | 572 | */ |
573 | -//@{ | |
573 | +//!@{ | |
574 | 574 | #define YB_Impl_Rational_fp_rational2(_op) \ |
575 | 575 | YB_Impl_Rational_fp_TmplHead_2 \ |
576 | 576 | yconstfn bool \ |
@@ -595,7 +595,7 @@ | ||
595 | 595 | YB_Impl_Rational_fp_rational2(>=) |
596 | 596 | |
597 | 597 | #undef YB_Impl_Rational_fp_rational2 |
598 | -//@} | |
598 | +//!@} | |
599 | 599 | |
600 | 600 | #undef YB_Impl_Rational_fp_TmplSig_2_r |
601 | 601 | #undef YB_Impl_Rational_fp_TmplSig_2_l |
@@ -643,7 +643,7 @@ | ||
643 | 643 | using make_fixed_t = fixed_point<conditional_t<_bSigned, |
644 | 644 | typename make_width_int<_vFrac + _vInt>::least_type, |
645 | 645 | typename make_width_int<_vFrac + _vInt>::unsigned_least_type>, _vFrac>; |
646 | -//@} | |
646 | +//!@} | |
647 | 647 | |
648 | 648 | } // namespace ystdex; |
649 | 649 |
@@ -651,7 +651,7 @@ | ||
651 | 651 | { |
652 | 652 | |
653 | 653 | //! \relates ystdex::fixed_point |
654 | -//@{ | |
654 | +//!@{ | |
655 | 655 | /*! |
656 | 656 | \brief std::common_type 的 ystdex::fixed_point 特化类型。 |
657 | 657 | \note 使用保留公共整数类型和整数位数策略选取公共类型。 |
@@ -679,7 +679,7 @@ | ||
679 | 679 | 当其它类型是浮点数时即为公共类型, |
680 | 680 | 否则 ystdex::fixed_point 的实例为公共类型。 |
681 | 681 | */ |
682 | -//@{ | |
682 | +//!@{ | |
683 | 683 | template<YB_Impl_Rational_fp_PList, typename _type> |
684 | 684 | struct common_type<ystdex::YB_Impl_Rational_fp_T, _type> |
685 | 685 | { |
@@ -702,10 +702,11 @@ | ||
702 | 702 | { |
703 | 703 | using type = ystdex::common_type_t<ystdex::YB_Impl_Rational_fp_T, _type>; |
704 | 704 | }; |
705 | -//@} | |
705 | +//!@} | |
706 | 706 | |
707 | 707 | |
708 | 708 | /*! |
709 | +\ingroup hashers | |
709 | 710 | \brief ystdex::fixed_point 散列支持。 |
710 | 711 | \since build 590 |
711 | 712 | */ |
@@ -828,7 +829,7 @@ | ||
828 | 829 | \see LWG 559 。 |
829 | 830 | \since build 668 |
830 | 831 | */ |
831 | -//@{ | |
832 | +//!@{ | |
832 | 833 | // XXX: The resolution of LWG 559 added the requirement to the standard |
833 | 834 | // specializations and the synopsis to ensure cv-qualified types, but there are |
834 | 835 | // no rules to require such standard specializations working with |
@@ -851,8 +852,8 @@ | ||
851 | 852 | class numeric_limits<const volatile ystdex::YB_Impl_Rational_fp_T> |
852 | 853 | : yimpl(public) numeric_limits<ystdex::YB_Impl_Rational_fp_T> |
853 | 854 | {}; |
854 | -//@} | |
855 | -//@} | |
855 | +//!@} | |
856 | +//!@} | |
856 | 857 | |
857 | 858 | #undef YB_Impl_Rational_fp_PList2 |
858 | 859 | #undef YB_Impl_Rational_fp_PList1 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2011-2016, 2018-2022 FrankHB. | |
2 | + © 2011-2016, 2018-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file ref.hpp |
12 | 12 | \ingroup YStandardEx |
13 | 13 | \brief 引用包装。 |
14 | -\version r530 | |
14 | +\version r548 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 588 |
17 | 17 | \par 创建时间: |
18 | 18 | 2015-03-28 22:29:20 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-02-07 23:09 +0800 | |
20 | + 2023-12-20 20:59 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -43,7 +43,7 @@ | ||
43 | 43 | { |
44 | 44 | |
45 | 45 | //! \since build 554 |
46 | -//@{ | |
46 | +//!@{ | |
47 | 47 | /*! |
48 | 48 | \brief 左值引用包装。 |
49 | 49 | \tparam _type 被包装的类型。 |
@@ -63,7 +63,7 @@ | ||
63 | 63 | 以允许具有引用包装值实例作为成员的类能在 ISO C++11 保证启用空基类优化; |
64 | 64 | 相关规则另见 Base 模块的说明。 |
65 | 65 | */ |
66 | -//@{ | |
66 | +//!@{ | |
67 | 67 | template<typename _type> |
68 | 68 | class lref |
69 | 69 | { |
@@ -74,7 +74,7 @@ | ||
74 | 74 | _type* ptr; |
75 | 75 | |
76 | 76 | //! \since build 870 |
77 | - //@{ | |
77 | + //!@{ | |
78 | 78 | static yconstfn _type* |
79 | 79 | fun(_type&) ynothrow; |
80 | 80 | static yconstfn _type* |
@@ -86,7 +86,7 @@ | ||
86 | 86 | lref(_type2&& u) ynoexcept(yimpl(noexcept(fun(std::declval<_type2>())))) |
87 | 87 | : ptr(ystdex::addressof(static_cast<_type&>(std::forward<_type2>(u)))) |
88 | 88 | {} |
89 | - //@} | |
89 | + //!@} | |
90 | 90 | //! \since build 556 |
91 | 91 | lref(const lref&) = default; |
92 | 92 |
@@ -122,7 +122,7 @@ | ||
122 | 122 | \brief 构造引用包装。 |
123 | 123 | \relates lref |
124 | 124 | */ |
125 | -//@{ | |
125 | +//!@{ | |
126 | 126 | template<typename _type> |
127 | 127 | yconstfn lref<_type> |
128 | 128 | ref(_type& t) |
@@ -142,8 +142,8 @@ | ||
142 | 142 | template<class _type> |
143 | 143 | void |
144 | 144 | cref(const _type&&) = delete; |
145 | -//@} | |
146 | -//@} | |
145 | +//!@} | |
146 | +//!@} | |
147 | 147 | |
148 | 148 | |
149 | 149 | /*! |
@@ -152,7 +152,7 @@ | ||
152 | 152 | \note 接口含义类似 boost::is_reference_wrapper 。 |
153 | 153 | \since build 675 |
154 | 154 | */ |
155 | -//@{ | |
155 | +//!@{ | |
156 | 156 | template<typename _type> |
157 | 157 | struct is_reference_wrapper : false_ |
158 | 158 | {}; |
@@ -164,7 +164,7 @@ | ||
164 | 164 | template<typename _type> |
165 | 165 | struct is_reference_wrapper<lref<_type>> : true_ |
166 | 166 | {}; |
167 | -//@} | |
167 | +//!@} | |
168 | 168 | |
169 | 169 | /*! |
170 | 170 | \ingroup transformation_traits |
@@ -172,14 +172,14 @@ | ||
172 | 172 | \see WG21 P0318R1 。 |
173 | 173 | \see LWG 3202 。 |
174 | 174 | */ |
175 | -//@{ | |
175 | +//!@{ | |
176 | 176 | /*! |
177 | 177 | \brief 取引用包装的类型或未被包装的模板参数类型。 |
178 | 178 | \note 含义类似 boost 和 std 中的同名接口。 |
179 | 179 | \note YStandardEx 扩展:支持 lref 的实例。 |
180 | 180 | \since build 675 |
181 | 181 | */ |
182 | -//@{ | |
182 | +//!@{ | |
183 | 183 | template<typename _type> |
184 | 184 | struct unwrap_reference |
185 | 185 | { |
@@ -200,19 +200,19 @@ | ||
200 | 200 | { |
201 | 201 | using type = _type&; |
202 | 202 | }; |
203 | -//@} | |
203 | +//!@} | |
204 | 204 | |
205 | 205 | |
206 | 206 | //! \since build 850 |
207 | -//@{ | |
207 | +//!@{ | |
208 | 208 | template<typename _type> |
209 | 209 | struct unwrap_ref_decay : unwrap_reference<decay_t<_type>> |
210 | 210 | {}; |
211 | 211 | |
212 | 212 | template<typename _type> |
213 | 213 | using unwrap_ref_decay_t = _t<unwrap_ref_decay<_type>>; |
214 | -//@} | |
215 | -//@} | |
214 | +//!@} | |
215 | +//!@} | |
216 | 216 | |
217 | 217 | |
218 | 218 | /*! |
@@ -248,7 +248,7 @@ | ||
248 | 248 | \note 默认仅提供对 std::reference_wrapper 和 lref 的实例类型的重载。 |
249 | 249 | \since build 348 |
250 | 250 | */ |
251 | -//@{ | |
251 | +//!@{ | |
252 | 252 | template<typename _type> |
253 | 253 | yconstfn _type& |
254 | 254 | unref(_type&& x) ynothrow |
@@ -269,7 +269,7 @@ | ||
269 | 269 | { |
270 | 270 | return x.get(); |
271 | 271 | } |
272 | -//@} | |
272 | +//!@} | |
273 | 273 | |
274 | 274 | |
275 | 275 | /*! |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2013-2016, 2018-2019, 2022 FrankHB. | |
2 | + © 2013-2016, 2018-2019, 2022-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file tuple.hpp |
12 | 12 | \ingroup YStandardEx |
13 | 13 | \brief 元组类型和操作。 |
14 | -\version r917 | |
14 | +\version r928 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 333 |
17 | 17 | \par 创建时间: |
18 | 18 | 2013-09-24 22:29:55 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-10-15 05:38 +0800 | |
20 | + 2023-12-20 20:37 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -42,20 +42,20 @@ | ||
42 | 42 | \ingroup transformation_traits |
43 | 43 | \since build 477 |
44 | 44 | */ |
45 | -//@{ | |
45 | +//!@{ | |
46 | 46 | #if __cpp_lib_tuple_element_t >= 201402L |
47 | 47 | using std::tuple_element_t; |
48 | 48 | #else |
49 | 49 | template<size_t _vIdx, typename _type> |
50 | 50 | using tuple_element_t = _t<std::tuple_element<_vIdx, _type>>; |
51 | 51 | #endif |
52 | -//@} | |
52 | +//!@} | |
53 | 53 | |
54 | 54 | } // inline namespace cpp2014; |
55 | 55 | |
56 | 56 | |
57 | 57 | //! \since build 589 |
58 | -//@{ | |
58 | +//!@{ | |
59 | 59 | namespace vseq |
60 | 60 | { |
61 | 61 |
@@ -92,7 +92,7 @@ | ||
92 | 92 | }; |
93 | 93 | |
94 | 94 | } // namespace vseq; |
95 | -//@} | |
95 | +//!@} | |
96 | 96 | |
97 | 97 | |
98 | 98 | /*! |
@@ -101,7 +101,7 @@ | ||
101 | 101 | \since build 651 |
102 | 102 | \todo 重命名为 \c variant_npos ,转移到合适的头文件。 |
103 | 103 | */ |
104 | -//@{ | |
104 | +//!@{ | |
105 | 105 | //! \brief 表示没有找到的索引。 |
106 | 106 | static yconstexpr const auto tuple_not_found(size_t(-1)); |
107 | 107 |
@@ -110,8 +110,7 @@ | ||
110 | 110 | { |
111 | 111 | |
112 | 112 | template<class _tSize, class _tIndex> |
113 | -using index_conv = size_t_<_tSize::value == _tIndex::value | |
114 | - ? tuple_not_found : _tIndex::value>; | |
113 | +using index_conv = size_t_<_tSize() == _tIndex() ? tuple_not_found : _tIndex()>; | |
115 | 114 | |
116 | 115 | } // namespace details; |
117 | 116 |
@@ -120,7 +119,7 @@ | ||
120 | 119 | \brief 查找类型对应的索引位置,若不存在则为 tuple_not_found 。 |
121 | 120 | \sa tuple_not_found |
122 | 121 | */ |
123 | -//@{ | |
122 | +//!@{ | |
124 | 123 | template<typename, class> |
125 | 124 | struct tuple_find; |
126 | 125 |
@@ -146,8 +145,8 @@ | ||
146 | 145 | struct tuple_find<_type, std::pair<_type1, _type2>> |
147 | 146 | : tuple_find<_type, std::tuple<_type1, _type2>> |
148 | 147 | {}; |
149 | -//@} | |
150 | -//@} | |
148 | +//!@} | |
149 | +//!@} | |
151 | 150 | |
152 | 151 | } // namespace ystdex; |
153 | 152 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2020-2021 FrankHB. | |
2 | + © 2020-2021, 2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file typeindex.h |
12 | 12 | \ingroup YStandardEx |
13 | 13 | \brief ISO C++ 类型索引扩展。 |
14 | -\version r112 | |
14 | +\version r116 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 892 |
17 | 17 | \par 创建时间: |
18 | 18 | 2020-06-12 20:28:55 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2021-12-29 01:17 +0800 | |
20 | + 2023-12-20 20:48 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -37,7 +37,7 @@ | ||
37 | 37 | { |
38 | 38 | |
39 | 39 | //! \since build 892 |
40 | -//@{ | |
40 | +//!@{ | |
41 | 41 | /*! |
42 | 42 | \brief 类型索引。 |
43 | 43 | \note 类似 std::type_index ,但包装 type_id_info 而不是 std::type_info 。 |
@@ -84,7 +84,7 @@ | ||
84 | 84 | #else |
85 | 85 | using std::type_index; |
86 | 86 | #endif |
87 | -//@} | |
87 | +//!@} | |
88 | 88 | |
89 | 89 | } // namespace ystdex; |
90 | 90 |
@@ -92,6 +92,7 @@ | ||
92 | 92 | { |
93 | 93 | |
94 | 94 | /*! |
95 | +\ingroup hashers | |
95 | 96 | \brief ystdex::type_id_info 散列支持。 |
96 | 97 | \since build 892 |
97 | 98 | */ |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2012-2014 FrankHB. | |
2 | + © 2012-2014, 2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file timing.hpp |
12 | 12 | \ingroup YTest |
13 | 13 | \brief 运行计时测试工具。 |
14 | -\version r338 | |
14 | +\version r340 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 308 |
17 | 17 | \par 创建时间: |
18 | 18 | 2012-06-23 20:01:09 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2014-10-04 15:10 +0800 | |
20 | + 2023-12-25 23:59 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -28,7 +28,7 @@ | ||
28 | 28 | #ifndef YB_INC_ytest_timing_hpp_ |
29 | 29 | #define YB_INC_ytest_timing_hpp_ 1 |
30 | 30 | |
31 | -#include "../ydef.h" | |
31 | +#include <ystdex/cstddef.h> // for ystdex::size_t; | |
32 | 32 | #include <ctime> |
33 | 33 | |
34 | 34 | /*! |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2019, 2022 FrankHB. | |
2 | + © 2019, 2022-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file node_base.cpp |
12 | 12 | \ingroup YStandardEx |
13 | 13 | \brief 作为节点序列容器实现的节点基础。 |
14 | -\version r176 | |
14 | +\version r197 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 865 |
17 | 17 | \par 创建时间: |
18 | 18 | 2019-08-22 17:48:43 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-11-28 19:55 +0800 | |
20 | + 2023-12-23 15:51 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -43,33 +43,19 @@ | ||
43 | 43 | { |
44 | 44 | std::swap(x.next, y.next), |
45 | 45 | std::swap(x.prev, y.prev); |
46 | - yunseq( | |
47 | - x.next->prev = x.prev->next = &x, | |
48 | - y.next->prev = y.prev->next = &y | |
49 | - ); | |
46 | + yunseq(x.next->prev = x.prev->next = &x, | |
47 | + y.next->prev = y.prev->next = &y); | |
50 | 48 | } |
51 | 49 | else |
52 | 50 | { |
53 | - yunseq( | |
54 | - y.next = x.next, | |
55 | - y.prev = x.prev | |
56 | - ); | |
57 | - yunseq( | |
58 | - y.next->prev = y.prev->next = &y, | |
59 | - x.next = x.prev = &x | |
60 | - ); | |
51 | + yunseq(y.next = x.next, y.prev = x.prev); | |
52 | + yunseq(y.next->prev = y.prev->next = &y, x.next = &x, x.prev = &x); | |
61 | 53 | } |
62 | 54 | } |
63 | 55 | else if(y.next != &y) |
64 | 56 | { |
65 | - yunseq( | |
66 | - x.next = y.next, | |
67 | - x.prev = y.prev | |
68 | - ); | |
69 | - yunseq( | |
70 | - x.next->prev = x.prev->next = &x, | |
71 | - y.next = y.prev = &y | |
72 | - ); | |
57 | + yunseq(x.next = y.next, x.prev = y.prev); | |
58 | + yunseq(x.next->prev = x.prev->next = &x, y.next = &y, y.prev = &y); | |
73 | 59 | } |
74 | 60 | } |
75 | 61 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2011-2021, 2023 FrankHB. | |
2 | + © 2011-2021, 2023-2024 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -12,13 +12,13 @@ | ||
12 | 12 | \ingroup YCLib |
13 | 13 | \ingroup DS |
14 | 14 | \brief DS 底层输入输出接口。 |
15 | -\version r1711 | |
15 | +\version r1715 | |
16 | 16 | \author FrankHB <frankhb1989@gmail.com> |
17 | 17 | \since build 604 |
18 | 18 | \par 创建时间: |
19 | 19 | 2015-06-06 03:01:27 +0800 |
20 | 20 | \par 修改时间: |
21 | - 2023-05-04 02:46 +0800 | |
21 | + 2024-02-26 01:15 +0800 | |
22 | 22 | \par 文本编码: |
23 | 23 | UTF-8 |
24 | 24 | \par 模块名称: |
@@ -30,11 +30,11 @@ | ||
30 | 30 | #define YCL_DS_INC_DSIO_h_ 1 |
31 | 31 | |
32 | 32 | #include "YCLib/YModules.h" |
33 | -#include YFM_YCLib_YCommon // for size_t; | |
33 | +#include YFM_YCLib_Platform | |
34 | 34 | #if YCL_DS |
35 | +# include YFM_YCLib_Basic // for size_t, noncopyable, nonmovable; | |
35 | 36 | # include YFM_YCLib_Reference // for lref; |
36 | 37 | # include <nds/disc_io.h> // for ::DISC_INTERFACE, ::sec_t; |
37 | -# include <ystdex/base.h> // for ystdex::noncopyable, ystdex::nonmomable; | |
38 | 38 | # include <ystdex/cache.hpp> // for ystdex::used_list_cache; |
39 | 39 | # include <ystdex/cstdio.h> //for ystdex::block_buffer; |
40 | 40 | # include YFM_YCLib_FileSystem // for platform::FAT, platform::Deref, |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2010-2017, 2021-2022 FrankHB. | |
2 | + © 2010-2017, 2021-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -12,13 +12,13 @@ | ||
12 | 12 | \ingroup Helper |
13 | 13 | \ingroup DS |
14 | 14 | \brief DS 平台框架。 |
15 | -\version r3243 | |
15 | +\version r3246 | |
16 | 16 | \author FrankHB <frankhb1989@gmail.com> |
17 | 17 | \since build 296 |
18 | 18 | \par 创建时间: |
19 | 19 | 2012-03-25 12:48:49 +0800 |
20 | 20 | \par 修改时间: |
21 | - 2022-09-03 22:31 +0800 | |
21 | + 2023-12-23 15:59 +0800 | |
22 | 22 | \par 文本编码: |
23 | 23 | UTF-8 |
24 | 24 | \par 模块名称: |
@@ -53,7 +53,8 @@ | ||
53 | 53 | { |
54 | 54 | |
55 | 55 | #if YCL_Win32 |
56 | -yconstexpr const double g_max_free_fps(1000); | |
56 | +//! \since build 982 | |
57 | +yconstexpr const uint16_t g_max_free_fps(1000); | |
57 | 58 | std::chrono::nanoseconds host_sleep(std::uint64_t(1000000000 / g_max_free_fps)); |
58 | 59 | #endif |
59 | 60 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2015-2022 FrankHB. | |
2 | + © 2015-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -12,13 +12,13 @@ | ||
12 | 12 | \ingroup YCLib |
13 | 13 | \ingroup DS |
14 | 14 | \brief DS 底层输入输出接口。 |
15 | -\version r4952 | |
15 | +\version r4973 | |
16 | 16 | \author FrankHB <frankhb1989@gmail.com> |
17 | 17 | \since build 604 |
18 | 18 | \par 创建时间: |
19 | 19 | 2015-06-06 06:25:00 +0800 |
20 | 20 | \par 修改时间: |
21 | - 2022-11-28 19:57 +0800 | |
21 | + 2023-12-20 20:30 +0800 | |
22 | 22 | \par 文本编码: |
23 | 23 | UTF-8 |
24 | 24 | \par 模块名称: |
@@ -27,7 +27,8 @@ | ||
27 | 27 | |
28 | 28 | |
29 | 29 | #include "YCLib/YModules.h" |
30 | -#include YFM_DS_YCLib_DSIO // for platform::Descriptions, std::runtime_error, | |
30 | +#include YFM_DS_YCLib_DSIO | |
31 | +#include YFM_YCLib_YCommon // for platform::Descriptions, std::runtime_error, | |
31 | 32 | // ystdex::throw_error, std::system_error, string, string_view, |
32 | 33 | // ystdex::exchange, ystdex::retry_on_cond, YAssertNonnull, FetchSeparator, |
33 | 34 | // ystdex::id, std::bind, std::placeholder::_1, ystdex::is_parent_or_self, |
@@ -210,18 +211,18 @@ | ||
210 | 211 | { |
211 | 212 | |
212 | 213 | //! \since build 610 |
213 | -//@{ | |
214 | +//!@{ | |
214 | 215 | // TODO: Support big endian implementations. |
215 | 216 | using ystdex::read_uint_le; |
216 | 217 | using ystdex::write_uint_le; |
217 | 218 | using ystdex::throw_error; |
218 | 219 | //! \since build 611 |
219 | -//@{ | |
220 | +//!@{ | |
220 | 221 | using std::system_error; |
221 | 222 | using std::errc; |
222 | 223 | // XXX: Coupled string types. |
223 | 224 | using CHRLib::MakeUCS2LE; |
224 | -//@} | |
225 | +//!@} | |
225 | 226 | |
226 | 227 | namespace |
227 | 228 | { |
@@ -258,7 +259,7 @@ | ||
258 | 259 | |
259 | 260 | |
260 | 261 | //! \since build 611 |
261 | -//@{ | |
262 | +//!@{ | |
262 | 263 | void |
263 | 264 | CheckThrowEIO(bool b) ythrow(system_error) |
264 | 265 | { |
@@ -280,10 +281,10 @@ | ||
280 | 281 | { |
281 | 282 | return tbl.ClusterToSector(pos.GetCluster()) + pos.GetSector(); |
282 | 283 | } |
283 | -//@} | |
284 | +//!@} | |
284 | 285 | |
285 | 286 | //! \since build 713 |
286 | -//@{ | |
287 | +//!@{ | |
287 | 288 | PDefH(void, CheckFillPartialSectorOff, const AllocationTable& tbl, |
288 | 289 | const FilePosition& pos, size_t offset, size_t n) ythrow(system_error) |
289 | 290 | ImplExpr(CheckThrowEIO( |
@@ -346,7 +347,7 @@ | ||
346 | 347 | PDefH(void, CheckWriteSectors, const AllocationTable& tbl, const FilePosition& |
347 | 348 | pos, const void* buf, size_t n) ythrow(system_error) |
348 | 349 | ImplRet(CheckThrowEIO(tbl.Cache.WriteSectors(PosToSec(tbl, pos), buf, n))) |
349 | -//@} | |
350 | +//!@} | |
350 | 351 | |
351 | 352 | //! \since build 656 |
352 | 353 | YB_ATTR_nodiscard bool |
@@ -380,7 +381,7 @@ | ||
380 | 381 | } |
381 | 382 | |
382 | 383 | } // unnamed namespace; |
383 | -//@} | |
384 | +//!@} | |
384 | 385 | |
385 | 386 | AllocationTable::AllocationTable(::sec_t start_sector, const byte* sec_buf, |
386 | 387 | size_t pages, size_t sectors_per_page_shift, Disc d) |
@@ -1508,6 +1509,12 @@ | ||
1508 | 1509 | st.st_atime = ConvertFileTime(read_uint_le<16>(dst + EntryData::ADate), 0), |
1509 | 1510 | st.st_mtime = ConvertFileTime(read_uint_le<16>( |
1510 | 1511 | dst + EntryData::MDate), read_uint_le<16>(dst + EntryData::MTime)), |
1512 | + // XXX: As libfat, ctime is reused as creation time, as no event to change | |
1513 | + // POSIX ctime is supported by FAT except the change of the file content | |
1514 | + // which is covered by mtime, so there is no clash. The meaning is | |
1515 | + // different in POSIX's %::stat, though. It is also different to Win32 | |
1516 | + // UCRT where mtime is synomym to ctime even for NTFS which has metadata | |
1517 | + // change events. | |
1511 | 1518 | st.st_ctime = ConvertFileTime(read_uint_le<16>( |
1512 | 1519 | dst + EntryData::CDate), read_uint_le<16>(dst + EntryData::CTime)), |
1513 | 1520 | // XXX: See https://github.com/devkitPro/newlib/commit/72ff9acad2ab54e80a19ddaec0106065c817e3f6 |
@@ -2200,7 +2207,7 @@ | ||
2200 | 2207 | using fres_t = decltype(f()); |
2201 | 2208 | using res_t = ystdex::nonvoid_result_t<fres_t, int>; |
2202 | 2209 | static yconstexpr const auto |
2203 | - de_val(std::is_pointer<fres_t>::value ? res_t() : res_t(-1)); | |
2210 | + de_val(std::is_pointer<fres_t>() ? res_t() : res_t(-1)); | |
2204 | 2211 | |
2205 | 2212 | TryRet(ystdex::invoke_for_value(0, f)) |
2206 | 2213 | CatchExpr(std::system_error& e, seterr(r, e.code().value())) |
@@ -2232,7 +2239,7 @@ | ||
2232 | 2239 | } |
2233 | 2240 | |
2234 | 2241 | //! \since build 764 |
2235 | -//@{ | |
2242 | +//!@{ | |
2236 | 2243 | template<class _tHolder, typename _fCallable, class _type, typename... _tParams> |
2237 | 2244 | inline auto |
2238 | 2245 | locked_invoke(_tHolder& holder, _fCallable&& f, _type& x, _tParams&&... args) |
@@ -2271,7 +2278,7 @@ | ||
2271 | 2278 | std::forward<_tParams>(args)...); |
2272 | 2279 | }); |
2273 | 2280 | } |
2274 | -//@} | |
2281 | +//!@} | |
2275 | 2282 | |
2276 | 2283 | //! \since build 826 |
2277 | 2284 | template<typename _fCheck, typename _fCallable, typename... _tParams> |
@@ -2325,7 +2332,7 @@ | ||
2325 | 2332 | |
2326 | 2333 | return int(file_struct); |
2327 | 2334 | }); |
2328 | - }, [] YB_LAMBDA_ANNOTATE((::_reent* r, void* fh) , ynothrowv, nonnull(2)){ | |
2335 | + }, [] YB_LAMBDA_ANNOTATE((::_reent* r, void* fh), ynothrowv, nonnull(2)){ | |
2329 | 2336 | // NOTE: The parameter %fd is actually cast from the file structure |
2330 | 2337 | // pointer stored by %devoptab_t::open_r. This function is called |
2331 | 2338 | // when the reference count in the handle decreased to zero. Since this |
@@ -101,6 +101,7 @@ | ||
101 | 101 | <ClInclude Include="include\NPL\SXML.h" /> |
102 | 102 | <ClInclude Include="include\NPL\YModules.h" /> |
103 | 103 | <ClInclude Include="include\YBaseMacro.h" /> |
104 | + <ClInclude Include="include\YCLib\Basic.h" /> | |
104 | 105 | <ClInclude Include="include\YCLib\Container.h" /> |
105 | 106 | <ClInclude Include="include\YCLib\Debug.h" /> |
106 | 107 | <ClInclude Include="include\YCLib\FileIO.h" /> |
@@ -745,6 +745,9 @@ | ||
745 | 745 | <ClInclude Include="include\NPL\NPLA1Root.h"> |
746 | 746 | <Filter>include\NPL</Filter> |
747 | 747 | </ClInclude> |
748 | + <ClInclude Include="include\YCLib\Basic.h"> | |
749 | + <Filter>include\YCLib</Filter> | |
750 | + </ClInclude> | |
748 | 751 | </ItemGroup> |
749 | 752 | <ItemGroup> |
750 | 753 | <ClCompile Include="source\YSLib\Adaptor\YNew.cpp"> |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2009-2015, 2018-2019, 2021-2022 FrankHB. | |
2 | + © 2009-2015, 2018-2019, 2021-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file CharacterProcessing.h |
12 | 12 | \ingroup CHRLib |
13 | 13 | \brief 字符编码处理。 |
14 | -\version r2420 | |
14 | +\version r2501 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 565 |
17 | 17 | \par 创建时间: |
18 | 18 | 2009-11-17 17:52:35 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-11-21 05:58 +0800 | |
20 | + 2023-12-20 20:33 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -71,11 +71,11 @@ | ||
71 | 71 | |
72 | 72 | |
73 | 73 | //! \return 转换的字节数。 |
74 | -//@{ | |
74 | +//!@{ | |
75 | 75 | //! \since build 641 |
76 | -//@{ | |
76 | +//!@{ | |
77 | 77 | //! \brief 按指定编码和转换状态转换字符串中的字符为 UCS-2 字符。 |
78 | -//@{ | |
78 | +//!@{ | |
79 | 79 | YF_API ConversionResult |
80 | 80 | MBCToUC(char16_t&, const char*&, Encoding, ConversionState&& = {}); |
81 | 81 | YF_API ConversionResult |
@@ -83,24 +83,24 @@ | ||
83 | 83 | inline PDefH(ConversionResult, MBCToUC, char16_t& uc, const char*& c, |
84 | 84 | Encoding enc, ConversionState& st) |
85 | 85 | ImplRet(MBCToUC(uc, c, enc, std::move(st))) |
86 | -//@} | |
86 | +//!@} | |
87 | 87 | /*! |
88 | 88 | \brief 按指定编码和转换状态转换字符流中的字符为 UCS-2 字符。 |
89 | 89 | \pre 断言:指针参数非空。 |
90 | 90 | */ |
91 | -//@{ | |
91 | +//!@{ | |
92 | 92 | YF_API YB_NONNULL(2) ConversionResult |
93 | 93 | MBCToUC(char16_t&, std::FILE*, Encoding, ConversionState&& = {}); |
94 | 94 | inline PDefH(ConversionResult, MBCToUC, char16_t& uc, std::FILE* fp, Encoding enc, |
95 | 95 | ConversionState& st) |
96 | 96 | ImplRet(MBCToUC(uc, fp, enc, std::move(st))) |
97 | -//@} | |
98 | -//@} | |
97 | +//!@} | |
98 | +//!@} | |
99 | 99 | /*! |
100 | 100 | \brief 按指定编码和转换状态返回转换字符为 UCS-2 字符的字节数。 |
101 | 101 | \since build 291 |
102 | 102 | */ |
103 | -//@{ | |
103 | +//!@{ | |
104 | 104 | YF_API ConversionResult |
105 | 105 | MBCToUC(const char*&, Encoding, ConversionState&& = {}); |
106 | 106 | //! \since build 614 |
@@ -114,14 +114,14 @@ | ||
114 | 114 | Encoding enc, ConversionState& st) |
115 | 115 | ImplRet(MBCToUC(c, e, enc, std::move(st))) |
116 | 116 | //! \pre 断言:指针参数非空。 |
117 | -//@{ | |
117 | +//!@{ | |
118 | 118 | YF_API YB_NONNULL(1) ConversionResult |
119 | 119 | MBCToUC(std::FILE*, Encoding, ConversionState&& = {}); |
120 | 120 | YB_NONNULL(1) inline PDefH(ConversionResult, MBCToUC, std::FILE* fp, |
121 | 121 | Encoding enc, ConversionState& st) |
122 | 122 | ImplRet(MBCToUC(fp, enc, std::move(st))) |
123 | -//@} | |
124 | -//@} | |
123 | +//!@} | |
124 | +//!@} | |
125 | 125 | |
126 | 126 | /*! |
127 | 127 | \brief 按指定编码转换 UCS-2 字符为字符串表示的多字节字符。 |
@@ -131,13 +131,13 @@ | ||
131 | 131 | */ |
132 | 132 | YF_API YB_NONNULL(1) size_t |
133 | 133 | UCToMBC(char*, const char16_t&, Encoding); |
134 | -//@} | |
134 | +//!@} | |
135 | 135 | |
136 | 136 | |
137 | 137 | //! \note 编码字节序同实现的 char16_t 存储字节序。 |
138 | -//@{ | |
138 | +//!@{ | |
139 | 139 | //! \since build 645 |
140 | -//@{ | |
140 | +//!@{ | |
141 | 141 | template<typename _func, typename _tDst, typename _tSrc> |
142 | 142 | YB_NONNULL(2, 3) size_t |
143 | 143 | TranscodeWith(_func f, _tDst* d, const _tSrc* s) |
@@ -165,10 +165,10 @@ | ||
165 | 165 | f(d, s, e); |
166 | 166 | return size_t(d - p); |
167 | 167 | } |
168 | -//@} | |
168 | +//!@} | |
169 | 169 | |
170 | 170 | //! \since build 644 |
171 | -//@{ | |
171 | +//!@{ | |
172 | 172 | template<typename _func, typename _tDst, typename _tSrc> |
173 | 173 | YB_NONNULL(2, 3) size_t |
174 | 174 | DecodeWith(_func f, _tDst* d, const _tSrc* s) |
@@ -209,18 +209,18 @@ | ||
209 | 209 | f(dst, src, end); |
210 | 210 | }, d, s, e); |
211 | 211 | } |
212 | -//@} | |
212 | +//!@} | |
213 | 213 | |
214 | 214 | /*! |
215 | 215 | \pre 断言:指针参数非空 。 |
216 | -\pre 第一参数指向的缓冲区能容纳转换后的 NTCTS (包括结尾的空字符)。 | |
216 | +\pre 第一参数指向的缓冲区能容纳转换后的 NTCTS(包括结尾的空字符)。 | |
217 | 217 | \pre 指针参数指向的缓冲区不重叠。 |
218 | 218 | \return 转换的串长。 |
219 | 219 | \since build 645 |
220 | 220 | */ |
221 | -//@{ | |
221 | +//!@{ | |
222 | 222 | //! \brief 按指定编码转换 MBCS 字符串为 UCS-2 字符串。 |
223 | -//@{ | |
223 | +//!@{ | |
224 | 224 | template<typename _func> |
225 | 225 | YB_NONNULL(2, 3) size_t |
226 | 226 | MBCSToUCS2(_func f, char16_t* d, const char* s) |
@@ -246,10 +246,10 @@ | ||
246 | 246 | MBCSToUCS2(char16_t*, const char*, const char* e); |
247 | 247 | YF_API YB_NONNULL(1, 2, 3) size_t |
248 | 248 | MBCSToUCS2(char16_t*, const char*, const char* e, Encoding); |
249 | -//@} | |
249 | +//!@} | |
250 | 250 | |
251 | 251 | //! \brief 按指定编码转换 MBCS 字符串为 UCS-4 字符串。 |
252 | -//@{ | |
252 | +//!@{ | |
253 | 253 | template<typename _func> |
254 | 254 | YB_NONNULL(2, 3) size_t |
255 | 255 | MBCSToUCS4(_func f, char32_t* d, const char* s) |
@@ -291,12 +291,12 @@ | ||
291 | 291 | MBCSToUCS4(char32_t*, const char*, const char*); |
292 | 292 | YF_API YB_NONNULL(1, 2, 3) size_t |
293 | 293 | MBCSToUCS4(char32_t*, const char*, const char*, Encoding); |
294 | -//@} | |
294 | +//!@} | |
295 | 295 | |
296 | 296 | //! \brief 按指定编码转换 UCS-2 字符串为 MBCS 字符串。 |
297 | -//@{ | |
297 | +//!@{ | |
298 | 298 | //! \since build 644 |
299 | -//@{ | |
299 | +//!@{ | |
300 | 300 | template<typename _func> |
301 | 301 | YB_NONNULL(2, 3) size_t |
302 | 302 | UCS2ToMBCS(_func f, char* d, const char16_t* s) |
@@ -314,7 +314,7 @@ | ||
314 | 314 | dst += f(dst, *src++); |
315 | 315 | }, d, s, e); |
316 | 316 | } |
317 | -//@} | |
317 | +//!@} | |
318 | 318 | YF_API YB_FLATTEN YB_NONNULL(1, 2) size_t |
319 | 319 | UCS2ToMBCS(char*, const char16_t*); |
320 | 320 | YF_API YB_NONNULL(1, 2) size_t |
@@ -323,23 +323,23 @@ | ||
323 | 323 | UCS2ToMBCS(char*, const char16_t*, const char16_t*); |
324 | 324 | YF_API YB_NONNULL(1, 2, 3) size_t |
325 | 325 | UCS2ToMBCS(char*, const char16_t*, const char16_t*, Encoding); |
326 | -//@} | |
326 | +//!@} | |
327 | 327 | |
328 | 328 | /*! |
329 | 329 | \brief 转换 UCS-2 字符串为 UCS-4 字符串。 |
330 | 330 | \since build 641 |
331 | 331 | */ |
332 | -//@{ | |
332 | +//!@{ | |
333 | 333 | YF_API YB_NONNULL(1, 2) size_t |
334 | 334 | UCS2ToUCS4(char32_t*, const char16_t*); |
335 | 335 | YF_API YB_NONNULL(1, 2, 3) size_t |
336 | 336 | UCS2ToUCS4(char32_t*, const char16_t*, const char16_t*); |
337 | -//@} | |
337 | +//!@} | |
338 | 338 | |
339 | 339 | //! \brief 按指定编码转换 UCS-4 字符串为 MBCS 字符串。 |
340 | -//@{ | |
340 | +//!@{ | |
341 | 341 | //! \since build 644 |
342 | -//@{ | |
342 | +//!@{ | |
343 | 343 | template<typename _func> |
344 | 344 | YB_NONNULL(2, 3) size_t |
345 | 345 | UCS4ToMBCS(_func f, char* d, const char32_t* s) |
@@ -357,7 +357,7 @@ | ||
357 | 357 | dst += f(dst, char16_t(*src++)); |
358 | 358 | }, d, s, e); |
359 | 359 | } |
360 | -//@} | |
360 | +//!@} | |
361 | 361 | YF_API YB_FLATTEN YB_NONNULL(1, 2) size_t |
362 | 362 | UCS4ToMBCS(char*, const char32_t*); |
363 | 363 | YF_API YB_NONNULL(1, 2) size_t |
@@ -366,23 +366,23 @@ | ||
366 | 366 | UCS4ToMBCS(char*, const char32_t*, const char32_t*); |
367 | 367 | YF_API YB_NONNULL(1, 2, 3) size_t |
368 | 368 | UCS4ToMBCS(char*, const char32_t*, const char32_t*, Encoding); |
369 | -//@} | |
369 | +//!@} | |
370 | 370 | |
371 | 371 | /*! |
372 | 372 | \brief 转换 UCS-4 字符串为 UCS-2 字符串。 |
373 | 373 | \since build 641 |
374 | 374 | */ |
375 | -//@{ | |
375 | +//!@{ | |
376 | 376 | YF_API YB_NONNULL(1, 2) size_t |
377 | 377 | UCS4ToUCS2(char16_t*, const char32_t*); |
378 | 378 | YF_API YB_NONNULL(1, 2, 3) size_t |
379 | 379 | UCS4ToUCS2(char16_t*, const char32_t*, const char32_t*); |
380 | -//@} | |
381 | -//@} | |
380 | +//!@} | |
381 | +//!@} | |
382 | 382 | |
383 | 383 | |
384 | 384 | //! \since build 645 |
385 | -//@{ | |
385 | +//!@{ | |
386 | 386 | template<Encoding, Encoding> |
387 | 387 | struct DispatchTranscoding; |
388 | 388 |
@@ -601,7 +601,7 @@ | ||
601 | 601 | return str; |
602 | 602 | } |
603 | 603 | }; |
604 | -//@} | |
604 | +//!@} | |
605 | 605 | |
606 | 606 | |
607 | 607 | /*! |
@@ -609,13 +609,13 @@ | ||
609 | 609 | \pre 断言:指针参数非空。 |
610 | 610 | \since build 645 |
611 | 611 | */ |
612 | -//@{ | |
612 | +//!@{ | |
613 | 613 | #define CHRLib_Impl_Transcode(_vFrom, _vTo, ...) \ |
614 | - return Transcoding<CharSet::_vFrom, CharSet::_vTo> \ | |
615 | - ::MakeTranscoded<_tDst>(__VA_ARGS__); | |
614 | + return Transcoding<CharSet::_vFrom, CharSet::_vTo>::MakeTranscoded<_tDst>( \ | |
615 | + __VA_ARGS__); | |
616 | 616 | #define CHRLib_Impl_TranscodeView(_vFrom, _vTo, ...) \ |
617 | - return Transcoding<CharSet::_vFrom, CharSet::_vTo> \ | |
618 | - ::MakeViewTranscoded<_tDst>(__VA_ARGS__); | |
617 | + return Transcoding<CharSet::_vFrom, CharSet::_vTo>::MakeViewTranscoded< \ | |
618 | + _tDst>(__VA_ARGS__); | |
619 | 619 | #define CHRLib_Impl_MakeTrans(_n, _tSrcChar, _tDstChar, _vFrom, _vTo, _vDeEnc) \ |
620 | 620 | template<class _tDst = std::basic_string<_tDstChar>, typename... _tParams> \ |
621 | 621 | YB_ATTR_nodiscard YB_NONNULL(1) YB_PURE _tDst \ |
@@ -646,92 +646,82 @@ | ||
646 | 646 | yforward(args)...); \ |
647 | 647 | } |
648 | 648 | //! \brief 转换指定编码的多字节字符串为指定类型的 UCS-2 字符串。 |
649 | -//@{ | |
649 | +//!@{ | |
650 | 650 | CHRLib_Impl_MakeTrans(UCS2LE, char, char16_t, Null, ISO_10646_UCS_2, CS_Default) |
651 | -//@} | |
651 | +//!@} | |
652 | 652 | /*! |
653 | 653 | \warning 假定本机字节序为小端序。 |
654 | 654 | \todo 支持字节序转换。 |
655 | 655 | */ |
656 | -//@{ | |
656 | +//!@{ | |
657 | 657 | /*! |
658 | 658 | \brief 构造指定类型的 UCS-2 字符串。 |
659 | 659 | \since build 641 |
660 | 660 | */ |
661 | 661 | template<class _tDst = std::basic_string<char16_t>> |
662 | -YB_ATTR_nodiscard YB_PURE inline _tDst | |
662 | +YB_ATTR_nodiscard YB_PURE yconstfn _tDst | |
663 | 663 | MakeUCS2LE(u16string_view sv, Encoding = CharSet::ISO_10646_UCS_2) |
664 | 664 | { |
665 | - const auto s(sv.data()); | |
666 | - | |
667 | - yconstraint(s); | |
668 | 665 | // TODO: Support correct conversion for encoding other than UCS-2LE. |
669 | - return {s, sv.length()}; | |
666 | + return yconstraint(sv.data()), _tDst(sv.data(), sv.length()); | |
670 | 667 | } |
671 | 668 | /*! |
672 | 669 | \brief 使用指定的分配器构造指定类型的 UCS-2 字符串。 |
673 | 670 | \since build 861 |
674 | 671 | */ |
675 | 672 | template<class _tDst = std::basic_string<char16_t>> |
676 | -YB_ATTR_nodiscard YB_PURE inline _tDst | |
673 | +YB_ATTR_nodiscard YB_PURE yconstfn _tDst | |
677 | 674 | MakeUCS2LE(std::allocator_arg_t, const typename _tDst::allocator_type& a, |
678 | 675 | u16string_view sv, Encoding = CharSet::ISO_10646_UCS_2) |
679 | 676 | { |
680 | - const auto s(sv.data()); | |
681 | - | |
682 | - yconstraint(s); | |
683 | 677 | // TODO: Support correct conversion for encoding other than UCS-2LE. |
684 | - return ystdex::make_obj_using_allocator<_tDst>(a, s, sv.length()); | |
678 | + return yconstraint(sv.data()), | |
679 | + ystdex::make_obj_using_allocator<_tDst>(a, sv.data(), sv.length()); | |
685 | 680 | } |
686 | 681 | //! \brief 转换 UCS-4 字符串为指定类型的 UCS-2 字符串。 |
687 | -//@{ | |
682 | +//!@{ | |
688 | 683 | CHRLib_Impl_MakeTrans(UCS2LE, char32_t, char16_t, ISO_10646_UCS_4, |
689 | 684 | ISO_10646_UCS_2, CharSet::ISO_10646_UCS_4) |
690 | -//@} | |
685 | +//!@} | |
691 | 686 | |
692 | 687 | //! \brief 转换指定编码的多字节字符串为指定类型的 UCS-4 字符串。 |
693 | -//@{ | |
688 | +//!@{ | |
694 | 689 | CHRLib_Impl_MakeTrans(UCS4LE, char, char32_t, Null, ISO_10646_UCS_4, CS_Default) |
695 | -//@} | |
690 | +//!@} | |
696 | 691 | //! \brief 转换 UCS-2 字符串为指定类型的 UCS-4 字符串。 |
697 | -//@{ | |
692 | +//!@{ | |
698 | 693 | CHRLib_Impl_MakeTrans(UCS4LE, char16_t, char32_t, ISO_10646_UCS_2, |
699 | 694 | ISO_10646_UCS_4, CharSet::ISO_10646_UCS_2) |
700 | -//@} | |
695 | +//!@} | |
701 | 696 | /*! |
702 | 697 | \brief 构造指定类型的 UCS-4 字符串。 |
703 | 698 | \since build 641 |
704 | 699 | */ |
705 | 700 | template<class _tDst = std::basic_string<char32_t>> |
706 | -YB_ATTR_nodiscard YB_PURE inline _tDst | |
701 | +YB_ATTR_nodiscard YB_PURE yconstfn _tDst | |
707 | 702 | MakeUCS4LE(u32string_view sv, Encoding = CharSet::ISO_10646_UCS_4) |
708 | 703 | { |
709 | - const auto s(sv.data()); | |
710 | - | |
711 | - yconstraint(s); | |
712 | 704 | // TODO: Support correct conversion for encoding other than UCS-4LE. |
713 | - return {s, sv.length()}; | |
705 | + return yconstraint(sv.data()), _tDst(sv.data(), sv.length()); | |
714 | 706 | } |
715 | 707 | /*! |
716 | 708 | \brief 使用指定的分配器构造指定类型的 UCS-4 字符串。 |
717 | 709 | \since build 861 |
718 | 710 | */ |
719 | 711 | template<class _tAlloc, class _tDst = std::basic_string<char32_t>> |
720 | -YB_ATTR_nodiscard YB_PURE inline _tDst | |
712 | +YB_ATTR_nodiscard YB_PURE yconstfn _tDst | |
721 | 713 | MakeUCS4LE(std::allocator_arg_t, const typename _tDst::allocator_type& a, |
722 | 714 | u32string_view sv, Encoding = CharSet::ISO_10646_UCS_4) |
723 | 715 | { |
724 | - const auto s(sv.data()); | |
725 | - | |
726 | - yconstraint(s); | |
727 | 716 | // TODO: Support correct conversion for encoding other than UCS-4LE. |
728 | - return ystdex::make_obj_using_allocator<_tDst>(a, s, sv.length()); | |
717 | + return yconstraint(sv.data()), | |
718 | + ystdex::make_obj_using_allocator<_tDst>(a, sv.data(), sv.length()); | |
729 | 719 | } |
730 | -//@} | |
720 | +//!@} | |
731 | 721 | |
732 | -//@{ | |
722 | +//!@{ | |
733 | 723 | //! \brief 转换 UTF-8 字符串为指定编码的多字节字符串。 |
734 | -//@{ | |
724 | +//!@{ | |
735 | 725 | //! \since build 544 |
736 | 726 | template<class _tDst = std::string> |
737 | 727 | YB_ATTR_nodiscard YB_NONNULL(1) YB_PURE inline _tDst |
@@ -767,20 +757,20 @@ | ||
767 | 757 | : MakeMBCS<_tDst>(std::allocator_arg, a, |
768 | 758 | MakeUCS2LE(std::allocator_arg, a, sv, CS_Default), enc); |
769 | 759 | } |
770 | -//@} | |
760 | +//!@} | |
771 | 761 | //! \brief 转换 UCS-2LE 字符串为指定编码的多字节字符串。 |
772 | -//@{ | |
762 | +//!@{ | |
773 | 763 | CHRLib_Impl_MakeTrans(MBCS, char16_t, char, ISO_10646_UCS_2, Null, CS_Default) |
774 | -//@} | |
764 | +//!@} | |
775 | 765 | //! \brief 转换 UCS-4LE 字符串为指定编码的多字节字符串。 |
776 | -//@{ | |
766 | +//!@{ | |
777 | 767 | CHRLib_Impl_MakeTrans(MBCS, char32_t, char, ISO_10646_UCS_4, Null, CS_Default) |
778 | -//@} | |
779 | -//@} | |
768 | +//!@} | |
769 | +//!@} | |
780 | 770 | #undef CHRLib_Impl_MakeTrans |
781 | 771 | #undef CHRLib_Impl_Transcode |
782 | 772 | #undef CHRLib_Impl_TranscodeView |
783 | -//@} | |
773 | +//!@} | |
784 | 774 | |
785 | 775 | } // namespace CHRLib; |
786 | 776 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2009-2017, 2019, 2021-2022 FrankHB. | |
2 | + © 2009-2017, 2019, 2021-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file StaticMapping.hpp |
12 | 12 | \ingroup CHRLib |
13 | 13 | \brief 静态编码映射。 |
14 | -\version r2657 | |
14 | +\version r2701 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 587 |
17 | 17 | \par 创建时间: |
18 | 18 | 2009-11-17 17:53:21 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-11-28 19:39 +0800 | |
20 | + 2023-12-20 20:33 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -39,7 +39,7 @@ | ||
39 | 39 | { |
40 | 40 | |
41 | 41 | //! \since build 644 |
42 | -//@{ | |
42 | +//!@{ | |
43 | 43 | /*! |
44 | 44 | \brief 检查解码迭代器。 |
45 | 45 | \pre is_undereferenceable 不抛出异常。 |
@@ -50,8 +50,8 @@ | ||
50 | 50 | { |
51 | 51 | using value_t = ystdex::remove_cvref_t<decltype(*i)>; |
52 | 52 | static_assert(ystdex::or_<std::is_convertible<value_t, byte>, |
53 | - ystdex::bool_<std::is_integral<value_t>::value | |
54 | - && sizeof(value_t) == 1>>(), "Invalid mapping source type found."); | |
53 | + ystdex::bool_<std::is_integral<value_t>() && sizeof(value_t) == 1>>(), | |
54 | + "Invalid mapping source type found."); | |
55 | 55 | using ystdex::is_undereferenceable; |
56 | 56 | |
57 | 57 | return !is_undereferenceable(i); |
@@ -61,7 +61,7 @@ | ||
61 | 61 | \brief 以输入迭代器指向内容填充有效输入迭代器指定的字节。 |
62 | 62 | \note 使用 ADL CheckIterator 检查迭代器。 |
63 | 63 | */ |
64 | -//@{ | |
64 | +//!@{ | |
65 | 65 | template<typename _tIn> |
66 | 66 | inline bool |
67 | 67 | FillByte(_tIn& i, byte& b) ynoexcept(noexcept(byte(*i)) && noexcept(++i)) |
@@ -82,8 +82,8 @@ | ||
82 | 82 | { |
83 | 83 | if(CheckIterator(i)) |
84 | 84 | { |
85 | - static_assert(!std::is_volatile<ystdex::remove_reference_t< | |
86 | - _tState>>::value, "Volatile state is not supported."); | |
85 | + static_assert(!std::is_volatile<ystdex::remove_reference_t<_tState> | |
86 | + >::value, "Volatile state is not supported."); | |
87 | 87 | const auto r = byte(*i); |
88 | 88 | |
89 | 89 | yunseq(++i, GetSequenceOf(st)[GetIndexOf(st)++] = r); |
@@ -105,12 +105,12 @@ | ||
105 | 105 | { |
106 | 106 | return pr.first.get() != pr.second ? FillByte(pr.first.get(), st) : false; |
107 | 107 | } |
108 | -//@} | |
109 | -//@} | |
108 | +//!@} | |
109 | +//!@} | |
110 | 110 | |
111 | 111 | |
112 | 112 | //! \since build 594 |
113 | -//@{ | |
113 | +//!@{ | |
114 | 114 | //! \brief 判断八元组是否组成 UTF-16 代理对起始代码的高 8 位。 |
115 | 115 | yconstfn PDefH(bool, IsSurrogateHead, octet x) ynothrow |
116 | 116 | ImplRet(x >= 0xD8 && x < 0xE0) |
@@ -128,7 +128,7 @@ | ||
128 | 128 | struct UCSMapperBase |
129 | 129 | { |
130 | 130 | //! \since build 641 |
131 | - //@{ | |
131 | + //!@{ | |
132 | 132 | static void |
133 | 133 | Assign(ystdex::pseudo_output, char32_t) ynothrow |
134 | 134 | {} |
@@ -140,7 +140,7 @@ | ||
140 | 140 | |
141 | 141 | uc = _tObj(c); |
142 | 142 | } |
143 | - //@} | |
143 | + //!@} | |
144 | 144 | |
145 | 145 | /*! |
146 | 146 | \brief 编码字符。 |
@@ -180,14 +180,14 @@ | ||
180 | 180 | 解码操作允许接受 ystdex::pseudo_output 忽略输出。 |
181 | 181 | 使用模板参数决定状态类型中,状态索引等于已解码的输入字节数;否则不予保证。 |
182 | 182 | */ |
183 | -//@{ | |
183 | +//!@{ | |
184 | 184 | template<Encoding> |
185 | 185 | class GUCSMapper |
186 | 186 | {}; |
187 | 187 | |
188 | 188 | /*! |
189 | 189 | \warning 使用 UCS-2 时, 4 字节代码点可能溢出。 |
190 | -\see 参考规范: RFC 3629 ,见 http://tools.ietf.org/html/rfc3629 。 | |
190 | +\see 参考规范:RFC 3629 ,见 http://tools.ietf.org/html/rfc3629 。 | |
191 | 191 | */ |
192 | 192 | template<> |
193 | 193 | struct GUCSMapper<CharSet::UTF_8> : UCSMapperBase |
@@ -198,14 +198,14 @@ | ||
198 | 198 | |
199 | 199 | private: |
200 | 200 | //! \since build 932 |
201 | - //@{ | |
201 | + //!@{ | |
202 | 202 | // XXX: See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90966. |
203 | 203 | #if YB_IMPL_GNUCPP && YB_IMPL_GNUCPP >= 90000 |
204 | 204 | using DecodeTableState = unsigned char; |
205 | 205 | #else |
206 | 206 | using DecodeTableState = std::uint_fast8_t; |
207 | 207 | #endif |
208 | - //@} | |
208 | + //!@} | |
209 | 209 | |
210 | 210 | template<typename _tObj, typename _tSeq> |
211 | 211 | static void |
@@ -237,7 +237,7 @@ | ||
237 | 237 | public: |
238 | 238 | /*! |
239 | 239 | \brief 检查 UTF-8 文本序列中非法字节。 |
240 | - \note 包括: C0 、 C1 、 F5 至 FF 。 | |
240 | + \note 包括:C0 、 C1 、 F5 至 FF 。 | |
241 | 241 | */ |
242 | 242 | YB_ATTR_nodiscard YB_STATELESS static yconstfn bool |
243 | 243 | IsInvalid(octet x) ynothrow |
@@ -246,14 +246,13 @@ | ||
246 | 246 | } |
247 | 247 | |
248 | 248 | /*! |
249 | - \brief 解码: UTF-8 。 | |
249 | + \brief 解码:UTF-8 。 | |
250 | 250 | \since build 599 |
251 | 251 | */ |
252 | 252 | template<typename _tObj, typename _tIn, typename _tState> |
253 | 253 | YB_ATTR_nodiscard static ConversionResult |
254 | - Decode(_tObj&& uc, _tIn&& i, _tState&& st) | |
255 | - ynoexcept(noexcept(GetSequenceOf(st)) && noexcept(GetIndexOf(st)) | |
256 | - && noexcept(!FillByte(i, st))) | |
254 | + Decode(_tObj&& uc, _tIn&& i, _tState&& st) ynoexcept(noexcept(GetSequenceOf( | |
255 | + st)) && noexcept(GetIndexOf(st)) && noexcept(!FillByte(i, st))) | |
257 | 256 | { |
258 | 257 | const auto seq(GetSequenceOf(st)); |
259 | 258 |
@@ -309,11 +308,11 @@ | ||
309 | 308 | return ConversionResult::OK; |
310 | 309 | } |
311 | 310 | /*! |
312 | - \brief 快速解码: UTF-8 。 | |
311 | + \brief 快速解码:UTF-8 。 | |
313 | 312 | \see https://github.com/miloyip/rapidjson/blob/master/include/rapidjson/encodings.h 。 |
314 | 313 | \since build 599 |
315 | 314 | */ |
316 | - //@{ | |
315 | + //!@{ | |
317 | 316 | template<typename _tObj, typename _tIn> |
318 | 317 | YB_ATTR_nodiscard static ConversionResult |
319 | 318 | Decode(_tObj&& uc, _tIn&& i, ConversionState& st) |
@@ -406,7 +405,7 @@ | ||
406 | 405 | { |
407 | 406 | return Decode(uc, yforward(i), st); |
408 | 407 | } |
409 | - //@} | |
408 | + //!@} | |
410 | 409 | |
411 | 410 | //! \since build 641 |
412 | 411 | template<typename _tOut> |
@@ -461,14 +460,13 @@ | ||
461 | 460 | using UCSMapperBase::Assign; |
462 | 461 | |
463 | 462 | /*! |
464 | - \brief 解码: UTF-16BE 。 | |
463 | + \brief 解码:UTF-16BE 。 | |
465 | 464 | \since build 599 |
466 | 465 | */ |
467 | 466 | template<typename _tObj, typename _tIn, typename _tState> |
468 | 467 | YB_ATTR_nodiscard static ConversionResult |
469 | - Decode(_tObj&& uc, _tIn&& i, _tState&& st) | |
470 | - ynoexcept(noexcept(GetSequenceOf(st)) | |
471 | - && noexcept(GetIndexOf(st)) && noexcept(!FillByte(i, st))) | |
468 | + Decode(_tObj&& uc, _tIn&& i, _tState&& st) ynoexcept(noexcept(GetSequenceOf( | |
469 | + st)) && noexcept(GetIndexOf(st)) && noexcept(!FillByte(i, st))) | |
472 | 470 | { |
473 | 471 | const auto seq(GetSequenceOf(st)); |
474 | 472 |
@@ -519,14 +517,13 @@ | ||
519 | 517 | using UCSMapperBase::Assign; |
520 | 518 | |
521 | 519 | /*! |
522 | - \brief 解码: UTF-16LE 。 | |
520 | + \brief 解码:UTF-16LE 。 | |
523 | 521 | \since build 599 |
524 | 522 | */ |
525 | 523 | template<typename _tObj, typename _tIn, typename _tState> |
526 | 524 | YB_ATTR_nodiscard static ConversionResult |
527 | - Decode(_tObj&& uc, _tIn&& i, _tState&& st) | |
528 | - ynoexcept(noexcept(GetSequenceOf(st)) | |
529 | - && noexcept(GetIndexOf(st)) && noexcept(!FillByte(i, st))) | |
525 | + Decode(_tObj&& uc, _tIn&& i, _tState&& st) ynoexcept(noexcept(GetSequenceOf( | |
526 | + st)) && noexcept(GetIndexOf(st)) && noexcept(!FillByte(i, st))) | |
530 | 527 | { |
531 | 528 | const auto seq(GetSequenceOf(st)); |
532 | 529 |
@@ -570,21 +567,20 @@ | ||
570 | 567 | } |
571 | 568 | }; |
572 | 569 | |
573 | -//! \see 参考规范: UAX #19 ,见 http://www.unicode.org/unicode/reports/tr19/ 。 | |
570 | +//! \see 参考规范:UAX #19 ,见 http://www.unicode.org/unicode/reports/tr19/ 。 | |
574 | 571 | template<> |
575 | 572 | struct GUCSMapper<CharSet::UTF_32BE> : UCSMapperBase |
576 | 573 | { |
577 | 574 | using UCSMapperBase::Assign; |
578 | 575 | |
579 | 576 | /*! |
580 | - \brief 解码: UTF-32BE 。 | |
577 | + \brief 解码:UTF-32BE 。 | |
581 | 578 | \since build 599 |
582 | 579 | */ |
583 | 580 | template<typename _tObj, typename _tIn, typename _tState> |
584 | 581 | YB_ATTR_nodiscard static ConversionResult |
585 | - Decode(_tObj&& uc, _tIn&& i, _tState&& st) | |
586 | - ynoexcept(noexcept(GetSequenceOf(st)) | |
587 | - && noexcept(GetIndexOf(st)) && noexcept(!FillByte(i, st))) | |
582 | + Decode(_tObj&& uc, _tIn&& i, _tState&& st) ynoexcept(noexcept(GetSequenceOf( | |
583 | + st)) && noexcept(GetIndexOf(st)) && noexcept(!FillByte(i, st))) | |
588 | 584 | { |
589 | 585 | const auto seq(GetSequenceOf(st)); |
590 | 586 |
@@ -615,21 +611,20 @@ | ||
615 | 611 | } |
616 | 612 | }; |
617 | 613 | |
618 | -//! \see 参考规范: UAX #19 ,见 http://www.unicode.org/unicode/reports/tr19/ 。 | |
614 | +//! \see 参考规范:UAX #19 ,见 http://www.unicode.org/unicode/reports/tr19/ 。 | |
619 | 615 | template<> |
620 | 616 | struct GUCSMapper<CharSet::UTF_32LE> : UCSMapperBase |
621 | 617 | { |
622 | 618 | using UCSMapperBase::Assign; |
623 | 619 | |
624 | 620 | /*! |
625 | - \brief 解码: UTF-32LE 。 | |
621 | + \brief 解码:UTF-32LE 。 | |
626 | 622 | \since build 599 |
627 | 623 | */ |
628 | 624 | template<typename _tObj, typename _tIn, typename _tState> |
629 | 625 | YB_ATTR_nodiscard static ConversionResult |
630 | - Decode(_tObj&& uc, _tIn&& i, _tState&& st) | |
631 | - ynoexcept(noexcept(GetSequenceOf(st)) | |
632 | - && noexcept(GetIndexOf(st)) && noexcept(!FillByte(i, st))) | |
626 | + Decode(_tObj&& uc, _tIn&& i, _tState&& st) ynoexcept(noexcept(GetSequenceOf( | |
627 | + st)) && noexcept(GetIndexOf(st)) && noexcept(!FillByte(i, st))) | |
633 | 628 | { |
634 | 629 | const auto seq(GetSequenceOf(st)); |
635 | 630 |
@@ -659,8 +654,8 @@ | ||
659 | 654 | return ConversionResult::OK; |
660 | 655 | } |
661 | 656 | }; |
662 | -//@} | |
663 | -//@} | |
657 | +//!@} | |
658 | +//!@} | |
664 | 659 | |
665 | 660 | } // namespace CHRLib; |
666 | 661 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2013-2016, 2020, 2022 FrankHB. | |
2 | + © 2013-2016, 2020, 2022-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file Environment.h |
12 | 12 | \ingroup Helper |
13 | 13 | \brief 环境。 |
14 | -\version r1160 | |
14 | +\version r1169 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 521 |
17 | 17 | \par 创建时间: |
18 | 18 | 2013-02-08 01:28:03 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-09-13 06:37 +0800 | |
20 | + 2023-12-20 20:34 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -55,7 +55,7 @@ | ||
55 | 55 | |
56 | 56 | #if YCL_Android |
57 | 57 | //! \since build 502 |
58 | -//@{ | |
58 | +//!@{ | |
59 | 59 | namespace Devices |
60 | 60 | { |
61 | 61 |
@@ -69,7 +69,7 @@ | ||
69 | 69 | class NativeHost; |
70 | 70 | |
71 | 71 | } // namespace Android; |
72 | -//@} | |
72 | +//!@} | |
73 | 73 | #endif |
74 | 74 | |
75 | 75 |
@@ -91,7 +91,7 @@ | ||
91 | 91 | */ |
92 | 92 | ValueNode Root{}; |
93 | 93 | //! \since build 954 |
94 | - //@{ | |
94 | + //!@{ | |
95 | 95 | ostringstream DefaultOutputStream; |
96 | 96 | //! \since build 955 |
97 | 97 | NPL::A1::GlobalState Global; |
@@ -103,7 +103,7 @@ | ||
103 | 103 | # if YF_Helper_Environment_NPL_UseBacktrace |
104 | 104 | NPL::ContextNode::ReducerSequence backtrace{Global.Allocator}; |
105 | 105 | # endif |
106 | - //@} | |
106 | + //!@} | |
107 | 107 | |
108 | 108 | public: |
109 | 109 | /*! |
@@ -116,17 +116,17 @@ | ||
116 | 116 | ~Environment(); |
117 | 117 | |
118 | 118 | //! \since build 688 |
119 | - //@{ | |
119 | + //!@{ | |
120 | 120 | /*! |
121 | 121 | \brief 取值类型根节点。 |
122 | 122 | \pre 断言:已初始化。 |
123 | 123 | */ |
124 | 124 | ValueNode& |
125 | 125 | GetRootRef() ynothrowv; |
126 | - //@} | |
126 | + //!@} | |
127 | 127 | |
128 | 128 | //! \since build 954 |
129 | - //@{ | |
129 | + //!@{ | |
130 | 130 | template<typename _func> |
131 | 131 | void |
132 | 132 | ExecuteNPLA1(_func f) |
@@ -170,7 +170,7 @@ | ||
170 | 170 | return NPL::A1::ReduceOnce(Term, ctx); |
171 | 171 | })); |
172 | 172 | } |
173 | - //@} | |
173 | + //!@} | |
174 | 174 | }; |
175 | 175 | |
176 | 176 | } // namespace YSLib; |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2009-2016, 2019-2020, 2022-2023 FrankHB. | |
2 | + © 2009-2016, 2019-2020, 2022-2024 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file Initialization.h |
12 | 12 | \ingroup Helper |
13 | 13 | \brief 框架初始化。 |
14 | -\version r915 | |
14 | +\version r955 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since 早于 build 132 |
17 | 17 | \par 创建时间: |
18 | 18 | 2009-10-21 23:15:08 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2023-03-30 02:59 +0800 | |
20 | + 2024-02-25 02:05 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -30,7 +30,7 @@ | ||
30 | 30 | |
31 | 31 | #include "YModules.h" |
32 | 32 | #include YFM_YSLib_Core_ValueNode // for string, ValueNode; |
33 | -#include YFM_YSLib_Service_FileSystem // for IO::Path; | |
33 | +#include YFM_YSLib_Service_FileSystem // for Deployment::RootPathBlock; | |
34 | 34 | #include YFM_YSLib_Core_YApplication // for Application; |
35 | 35 | #include YFM_YSLib_Adaptor_Font // for Drawing::FontCache; |
36 | 36 | #include YFM_YSLib_Service_ContentType // for MIMEBiMapping; |
@@ -57,51 +57,14 @@ | ||
57 | 57 | TraceForOutermost(const std::exception&, RecordLevel) ynothrow; |
58 | 58 | |
59 | 59 | |
60 | -//! \since build 899 | |
61 | -//!@{ | |
62 | -/*! | |
63 | -\brief 判断指定程序映像的路径字符串指示的位置是否符合局部 FHS 目录布局。 | |
64 | -\see https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html 。 | |
65 | - | |
66 | -以 POSIX 环境变量语法,预期的局部用户目录布局为: | |
67 | -$PREFIX/ | |
68 | -$PREFIX/$BIN/ | |
69 | -$PREFIX/lib/ | |
70 | -$PREFIX/share/ | |
71 | -其中,$PREFIX 为路径前缀,$BIN 是任意非空的目录名。 | |
72 | -当参数指定 $PREFIX/$BIN/ 目录,且以上路径以目录存在时,检查通过。 | |
73 | -假定检查目录时,布局不改变。 | |
74 | -实现可分别检查各项路径,而不要求避免外部并发访问的竞争。 | |
75 | -*/ | |
76 | -YB_ATTR_nodiscard YF_API YB_PURE bool | |
77 | -CheckLocalFHSLayout(const string&); | |
78 | - | |
79 | 60 | /*! |
80 | -\brief 取根路径字符串对应的局部 FHS 根路径。 | |
81 | -\sa FetchRootPathString | |
82 | -\sa GetLocalFHSRootPathOf | |
83 | -*/ | |
84 | -YB_ATTR_nodiscard YF_API YB_PURE const IO::Path& | |
85 | -FetchLocalFHSRootPath(); | |
86 | - | |
87 | -/*! | |
88 | -\brief 取框架根路径字符串。 | |
89 | -\return 以平台路径分隔符结尾的目录路径字符串。 | |
61 | +\brief 取根路径字符串对应的根路径块。 | |
62 | +\note 在首次调用时会初始化并缓存到静态存储。 | |
63 | +\sa Deployment::RootPathBlock | |
64 | +\since build 982 | |
90 | 65 | */ |
91 | -YB_ATTR_nodiscard YF_API YB_PURE const string& | |
92 | -FetchRootPathString(); | |
93 | - | |
94 | -/*! | |
95 | -\brief 取指定程序映像的路径字符串对应的局部 fHS 根路径。 | |
96 | -\sa CheckLocalFHSLayout | |
97 | -\sa FetchRootPathString | |
98 | - | |
99 | -若框架根路径的 CheckLocalFHSLayout 检查通过,局部 fHS 根路径为对应的 $PREFIX ; | |
100 | -否则,局部 fHS 根路径路径为空。 | |
101 | -*/ | |
102 | -YB_ATTR_nodiscard YF_API YB_PURE IO::Path | |
103 | -GetLocalFHSRootPathOf(const string&); | |
104 | -//!@} | |
66 | +YB_ATTR_nodiscard YB_PURE const Deployment::RootPathBlock& | |
67 | +FetchRootPathBlock(); | |
105 | 68 | |
106 | 69 | |
107 | 70 | //! \since build 971 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2010-2016, 2019, 2021-2022 FrankHB. | |
2 | + © 2010-2016, 2019, 2021-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file ShellHelper.h |
12 | 12 | \ingroup Helper |
13 | 13 | \brief Shell 助手模块。 |
14 | -\version r2065 | |
14 | +\version r2085 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 278 |
17 | 17 | \par 创建时间: |
18 | 18 | 2010-03-14 14:07:22 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-01-21 20:38 +0800 | |
20 | + 2023-12-20 20:10 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -30,7 +30,6 @@ | ||
30 | 30 | |
31 | 31 | #include <Helper/YModules.h> |
32 | 32 | #include <YCLib/YModules.h> |
33 | -#include YFM_YCLib_Debug | |
34 | 33 | #include YFM_YSLib_UI_YDesktop // for UI::Desktop; |
35 | 34 | #include YFM_YSLib_Core_YApplication // for Shell, FetchAppInstance; |
36 | 35 | #include YFM_YSLib_Service_YTimer // for Timers::HighResolutionClock; |
@@ -90,7 +89,7 @@ | ||
90 | 89 | |
91 | 90 | virtual DefDeDtor(GShellSession) |
92 | 91 | |
93 | - DefGetter(const ynothrow, _tShell&, Shell, conn) | |
92 | + YB_ATTR_nodiscard DefGetter(const ynothrow, _tShell&, Shell, conn) | |
94 | 93 | }; |
95 | 94 | |
96 | 95 |
@@ -121,7 +120,7 @@ | ||
121 | 120 | |
122 | 121 | |
123 | 122 | //! \ingroup helper_functions |
124 | -//@{ | |
123 | +//!@{ | |
125 | 124 | /*! |
126 | 125 | \brief 取指定 Shell 句柄对应的 Shell 引用 。 |
127 | 126 | \since build 205 |
@@ -138,25 +137,25 @@ | ||
138 | 137 | \brief 判断句柄指定的 Shell 是否为当前线程空间中运行的 Shell 。 |
139 | 138 | \since 早于 build 132 |
140 | 139 | */ |
141 | -inline PDefH(bool, IsNowShell, const shared_ptr<Shell>& hShl) | |
142 | - ImplRet(FetchAppInstance().GetShellHandle() == hShl) | |
140 | +inline PDefH(bool, IsNowShell, const shared_ptr<Shell>& h) | |
141 | + ImplRet(FetchAppInstance().GetShellHandle() == h) | |
143 | 142 | |
144 | 143 | /*! |
145 | 144 | \brief 向句柄指定的 Shell 对象转移线程控制权。 |
146 | -\since build 594 | |
145 | +\since build 955 | |
147 | 146 | */ |
148 | -inline PDefH(void, NowShellTo, const shared_ptr<Shell>& hShl) | |
149 | - ImplExpr(Activate(hShl)) | |
147 | +inline PDefH(void, NowShellTo, shared_ptr<Shell> h) | |
148 | + ImplExpr(Activate(std::move(h))) | |
150 | 149 | |
151 | 150 | /*! |
152 | 151 | \brief 通过主消息队列向指定 Shell 对象转移控制权。 |
153 | 152 | \since 早于 build 132 |
154 | 153 | */ |
155 | -inline PDefH(void, SetShellTo, const shared_ptr<Shell>& hShl, | |
154 | +inline PDefH(void, SetShellTo, const shared_ptr<Shell>& h, | |
156 | 155 | Messaging::Priority prior = Messaging::NormalPriority) |
157 | 156 | // NOTE: It would make the message loop in dead lock when called more |
158 | 157 | // than once specifying on same destination shell. |
159 | - ImplRet(PostMessage<SM_Set>(prior, hShl)) | |
158 | + ImplRet(PostMessage<SM_Set>(prior, h)) | |
160 | 159 | |
161 | 160 | |
162 | 161 | /*! |
@@ -199,13 +198,13 @@ | ||
199 | 198 | \warning 非线程安全。 |
200 | 199 | \since build 307 |
201 | 200 | */ |
202 | -//@{ | |
201 | +//!@{ | |
203 | 202 | YF_API YB_ATTR_returns_nonnull const char* |
204 | 203 | TranslateTime(const std::tm&, const char* = DefaultTimeFormat); |
205 | 204 | //! \since build 563 |
206 | 205 | YF_API YB_ATTR_returns_nonnull const char* |
207 | 206 | TranslateTime(const std::time_t&, const char* = DefaultTimeFormat); |
208 | -//@} | |
207 | +//!@} | |
209 | 208 | |
210 | 209 | |
211 | 210 | /*! |
@@ -252,10 +251,12 @@ | ||
252 | 251 | \brief 取内部计数。 |
253 | 252 | \since build 405 |
254 | 253 | */ |
255 | - //@{ | |
256 | - DefGetter(const ynothrow, std::chrono::nanoseconds, LastTick, last_tick) | |
257 | - DefGetter(const ynothrow, std::chrono::nanoseconds, NowTick, now_tick) | |
258 | - //@} | |
254 | + //!@{ | |
255 | + YB_ATTR_nodiscard | |
256 | + DefGetter(const ynothrow, std::chrono::nanoseconds, LastTick, last_tick) | |
257 | + YB_ATTR_nodiscard | |
258 | + DefGetter(const ynothrow, std::chrono::nanoseconds, NowTick, now_tick) | |
259 | + //!@} | |
259 | 260 | |
260 | 261 | /*! |
261 | 262 | \brief 刷新:更新计数器内部计数。 |
@@ -266,7 +267,7 @@ | ||
266 | 267 | Refresh(); |
267 | 268 | }; |
268 | 269 | |
269 | -//@} | |
270 | +//!@} | |
270 | 271 | |
271 | 272 | namespace UI |
272 | 273 | { |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2012-2016, 2019-2022 FrankHB. | |
2 | + © 2012-2016, 2019-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file Configuration.h |
12 | 12 | \ingroup NPL |
13 | 13 | \brief 配置设置。 |
14 | -\version r468 | |
14 | +\version r483 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 334 |
17 | 17 | \par 创建时间: |
18 | 18 | 2012-08-27 15:15:08 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-09-23 01:04 +0800 | |
20 | + 2023-12-20 20:33 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -63,14 +63,14 @@ | ||
63 | 63 | GlobalState::NoSourceInformation>(), yforward(obj), cs)); |
64 | 64 | } |
65 | 65 | |
66 | - DefGetter(const ynothrow, ContextState&, Context, cs) | |
66 | + YB_ATTR_nodiscard DefGetter(const ynothrow, ContextState&, Context, cs) | |
67 | 67 | }; |
68 | 68 | |
69 | 69 | } // namespace A1; |
70 | 70 | |
71 | 71 | |
72 | 72 | /*! |
73 | -\brief 设置:使用 S 表达式存储外部状态。 | |
73 | +\brief 配置:使用 S 表达式存储外部状态。 | |
74 | 74 | \warning 非虚析构。 |
75 | 75 | \since build 334 |
76 | 76 | */ |
@@ -116,7 +116,7 @@ | ||
116 | 116 | {} |
117 | 117 | DefDeCopyMoveCtorAssignment(Configuration) |
118 | 118 | |
119 | - DefGetter(const ynothrow, const ValueNode&, Root, root) | |
119 | + YB_ATTR_nodiscard DefGetter(const ynothrow, const ValueNode&, Root, root) | |
120 | 120 | |
121 | 121 | /*! |
122 | 122 | \brief 从文件输入设置。 |
@@ -128,12 +128,13 @@ | ||
128 | 128 | operator>>(std::istream&, Configuration&); |
129 | 129 | |
130 | 130 | //! \since build 344 |
131 | - DefGetter(const ynothrow, const ValueNode&, Node, root) | |
131 | + YB_ATTR_nodiscard DefGetter(const ynothrow, const ValueNode&, Node, root) | |
132 | 132 | /*! |
133 | - \brief 取设置节点的右值引用。 | |
133 | + \brief 取配置节点的右值引用。 | |
134 | 134 | \since build 341 |
135 | 135 | */ |
136 | - DefGetter(ynothrow, ValueNode&&, NodeRRef, std::move(root)) | |
136 | + YB_ATTR_nodiscard | |
137 | + DefGetter(ynothrow, ValueNode&&, NodeRRef, std::move(root)) | |
137 | 138 | |
138 | 139 | //! \since build 955 |
139 | 140 | YB_ATTR_nodiscard YB_PURE |
@@ -142,13 +143,20 @@ | ||
142 | 143 | }; |
143 | 144 | |
144 | 145 | /*! |
145 | -\brief 输出设置至输出流。 | |
146 | +\brief 输出配置至输出流。 | |
146 | 147 | \relates Configuration |
147 | 148 | \since build 600 |
148 | 149 | */ |
149 | 150 | YF_API std::ostream& |
150 | 151 | operator<<(std::ostream&, const Configuration&); |
151 | 152 | |
153 | +/*! | |
154 | +\brief 写 UTF-8 BOM 和配置到文件流。 | |
155 | +\since build 982 | |
156 | +*/ | |
157 | +YF_API void | |
158 | +WriteNPLA1StreamWithBOM(std::ostream&, NPL::Configuration&&); | |
159 | + | |
152 | 160 | } // namespace NPL; |
153 | 161 | |
154 | 162 | #endif |
@@ -0,0 +1,112 @@ | ||
1 | +/* | |
2 | + © 2010-2016, 2024 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 | + | |
11 | +/*! \file Basic.h | |
12 | +\ingroup YCLib | |
13 | +\brief 基本接口。 | |
14 | +\version r1245 | |
15 | +\author FrankHB <frankhb1989@gmail.com> | |
16 | +\since build 593 | |
17 | +\par 创建时间: | |
18 | + 2024-02-25 21:45:35 +0800 | |
19 | +\par 修改时间: | |
20 | + 2024-02-26 01:10 +0800 | |
21 | +\par 文本编码: | |
22 | + UTF-8 | |
23 | +\par 模块名称: | |
24 | + YCLib::Basic | |
25 | +*/ | |
26 | + | |
27 | + | |
28 | +#ifndef YCL_INC_Basic_h_ | |
29 | +#define YCL_INC_Basic_h_ 1 | |
30 | + | |
31 | +#include "YModules.h" | |
32 | +#include <ystdex/cstddef.h> // for ystdex::byte, ystdex::octet, | |
33 | +// ystdex::ptrdiff_t, ystdex::size_t, ystdex::nullptr_t; | |
34 | +#include <ystdex/base.h> // for ystdex::noncopyable, ystdex::nonmovable; | |
35 | +#include <tuple> // for std::forward_as_tuple, std::get, std::ignore, | |
36 | +// std::make_tuple, std::tie, std::tuple, std::tuple_cat; | |
37 | +#include <utility> // for std::get, std::make_pair, std::pair: | |
38 | +#include <ystdex/range.hpp> // for ystdex::size; | |
39 | + | |
40 | +/*! \defgroup TopLevelPlatformNamespaces Top-level Platform Namespaces | |
41 | +\brief 顶级平台命名空间。 | |
42 | +\since build 652 | |
43 | +*/ | |
44 | + | |
45 | +//! \ingroup TopLevelPlatformNamespaces | |
46 | +namespace platform | |
47 | +{ | |
48 | + | |
49 | +//! \since build 593 | |
50 | +inline namespace basic_types | |
51 | +{ | |
52 | + | |
53 | +/*! | |
54 | +\brief 平台通用数据类型。 | |
55 | +\since build 209 | |
56 | +*/ | |
57 | +//!@{ | |
58 | +//! \since build 417 | |
59 | +using ystdex::byte; | |
60 | +//! \since build 417 | |
61 | +using ystdex::octet; | |
62 | +using ystdex::ptrdiff_t; | |
63 | +using ystdex::size_t; | |
64 | +//! \since build 644 | |
65 | +using ystdex::nullptr_t; | |
66 | +//!@} | |
67 | + | |
68 | +//! \since build 209 | |
69 | +using ystdex::noncopyable; | |
70 | +//! \since build 373 | |
71 | +using ystdex::nonmovable; | |
72 | + | |
73 | +} // inline namespace basic_types; | |
74 | + | |
75 | +//! \since build 843 | |
76 | +inline namespace basic_utilities | |
77 | +{ | |
78 | + | |
79 | +using std::forward_as_tuple; | |
80 | +using std::get; | |
81 | +using std::ignore; | |
82 | +using std::make_pair; | |
83 | +using std::make_tuple; | |
84 | +using std::pair; | |
85 | +using std::tie; | |
86 | +using std::tuple; | |
87 | +using std::tuple_cat; | |
88 | + | |
89 | +//! \since build 546 | |
90 | +using std::begin; | |
91 | +//! \since build 546 | |
92 | +using std::end; | |
93 | + | |
94 | +//! \since build 664 | |
95 | +using ystdex::size; | |
96 | + | |
97 | +} // inline namespace utilities; | |
98 | + | |
99 | +} // namespace platform; | |
100 | + | |
101 | +//! \ingroup TopLevelPlatformNamespaces | |
102 | +namespace platform_ex | |
103 | +{ | |
104 | + | |
105 | +using namespace platform::basic_types; | |
106 | +//! \since build 843 | |
107 | +using namespace platform::basic_utilities; | |
108 | + | |
109 | +} // namespace platform_ex; | |
110 | + | |
111 | +#endif | |
112 | + |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2010-2016, 2018-2023 FrankHB. | |
2 | + © 2010-2016, 2018-2024 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file Container.h |
12 | 12 | \ingroup YCLib |
13 | 13 | \brief 容器、拟容器和适配器。 |
14 | -\version r1476 | |
14 | +\version r1509 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 593 |
17 | 17 | \par 创建时间: |
18 | 18 | 2010-10-09 09:25:26 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2023-02-17 23:09 +0800 | |
20 | + 2024-02-25 21:48 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -29,6 +29,7 @@ | ||
29 | 29 | #define YCL_INC_Container_h_ 1 |
30 | 30 | |
31 | 31 | #include "YModules.h" |
32 | +#include YFM_YCLib_Basic // for pair; | |
32 | 33 | #include <ystdex/cassert.h> // for YAssertNonnull; |
33 | 34 | #include <ystdex/memory_resource.h> // for ystdex::pmr; |
34 | 35 | #include <ystdex/functor.hpp> // for ystdex::less, ystdex::equal_to; |
@@ -74,30 +75,6 @@ | ||
74 | 75 | //! \since build 843 |
75 | 76 | namespace pmr = ystdex::pmr; |
76 | 77 | |
77 | -//! \since build 843 | |
78 | -inline namespace basic_utilities | |
79 | -{ | |
80 | - | |
81 | -using std::forward_as_tuple; | |
82 | -using std::get; | |
83 | -using std::ignore; | |
84 | -using std::make_pair; | |
85 | -using std::make_tuple; | |
86 | -using std::pair; | |
87 | -using std::tie; | |
88 | -using std::tuple; | |
89 | -using std::tuple_cat; | |
90 | - | |
91 | -//! \since build 546 | |
92 | -using std::begin; | |
93 | -//! \since build 546 | |
94 | -using std::end; | |
95 | - | |
96 | -//! \since build 664 | |
97 | -using ystdex::size; | |
98 | - | |
99 | -} // inline namespace utilities; | |
100 | - | |
101 | 78 | //! \since build 593 |
102 | 79 | inline namespace containers |
103 | 80 | { |
@@ -149,12 +126,12 @@ | ||
149 | 126 | // is an implementation detail. |
150 | 127 | template<typename _tKey, typename _tMapped, typename _fComp |
151 | 128 | = ystdex::less<_tKey>, class _tAlloc |
152 | - = default_allocator<std::pair<const _tKey, _tMapped>>> | |
129 | + = default_allocator<pair<const _tKey, _tMapped>>> | |
153 | 130 | using map = ystdex::map<_tKey, _tMapped, _fComp, _tAlloc>; |
154 | 131 | |
155 | 132 | template<typename _tKey, typename _tMapped, typename _fComp |
156 | 133 | = ystdex::less<_tKey>, class _tAlloc |
157 | - = default_allocator<std::pair<const _tKey, _tMapped>>> | |
134 | + = default_allocator<pair<const _tKey, _tMapped>>> | |
158 | 135 | using multimap = stdd::multimap<_tKey, _tMapped, _fComp, _tAlloc>; |
159 | 136 | |
160 | 137 | template<typename _tKey, typename _fComp = ystdex::less<_tKey>, |
@@ -168,13 +145,13 @@ | ||
168 | 145 | |
169 | 146 | template<typename _tKey, typename _tMapped, |
170 | 147 | typename _fHash = ystdex::hash<_tKey>, typename _fPred = ystdex::equal_to< |
171 | - _tKey>, class _tAlloc = default_allocator<std::pair<const _tKey, _tMapped>>> | |
148 | + _tKey>, class _tAlloc = default_allocator<pair<const _tKey, _tMapped>>> | |
172 | 149 | using unordered_map |
173 | 150 | = ystdex::unordered_map<_tKey, _tMapped, _fHash, _fPred, _tAlloc>; |
174 | 151 | |
175 | 152 | template<typename _tKey, typename _tMapped, |
176 | 153 | typename _fHash = ystdex::hash<_tKey>, typename _fPred = ystdex::equal_to< |
177 | - _tKey>, class _tAlloc = default_allocator<std::pair<const _tKey, _tMapped>>> | |
154 | + _tKey>, class _tAlloc = default_allocator<pair<const _tKey, _tMapped>>> | |
178 | 155 | using unordered_multimap |
179 | 156 | = stdd::unordered_multimap<_tKey, _tMapped, _fHash, _fPred, _tAlloc>; |
180 | 157 |
@@ -311,7 +288,7 @@ | ||
311 | 288 | # else |
312 | 289 | template<typename _tKey, typename _tMapped, typename _fComp |
313 | 290 | = ystdex::less<_tKey>, class _tAlloc |
314 | - = default_allocator<std::pair<const _tKey, _tMapped>>> | |
291 | + = default_allocator<pair<const _tKey, _tMapped>>> | |
315 | 292 | using value_multimap = multimap<_tKey, _tMapped, _fComp, _tAlloc>; |
316 | 293 | # endif |
317 | 294 |
@@ -331,12 +308,12 @@ | ||
331 | 308 | |
332 | 309 | template<typename _tKey, typename _tMapped, |
333 | 310 | typename _fHash = ystdex::hash<_tKey>, typename _fPred = ystdex::equal_to< |
334 | - _tKey>, class _tAlloc = default_allocator<std::pair<const _tKey, _tMapped>>> | |
311 | + _tKey>, class _tAlloc = default_allocator<pair<const _tKey, _tMapped>>> | |
335 | 312 | using linked_map = unordered_map<_tKey, _tMapped, _fHash, _fPred, _tAlloc>; |
336 | 313 | |
337 | 314 | template<typename _tKey, typename _tMapped, |
338 | 315 | typename _fHash = ystdex::hash<_tKey>, typename _fPred = ystdex::equal_to< |
339 | - _tKey>, class _tAlloc = default_allocator<std::pair<const _tKey, _tMapped>>> | |
316 | + _tKey>, class _tAlloc = default_allocator<pair<const _tKey, _tMapped>>> | |
340 | 317 | using linked_multimap |
341 | 318 | = unordered_multimap<_tKey, _tMapped, _fHash, _fPred, _tAlloc>; |
342 | 319 |
@@ -364,7 +341,7 @@ | ||
364 | 341 | # else |
365 | 342 | template<typename _tKey, typename _tMapped, typename _fComp |
366 | 343 | = ystdex::less<_tKey>, class _tAlloc |
367 | - = default_allocator<std::pair<const _tKey, _tMapped>>> | |
344 | + = default_allocator<pair<const _tKey, _tMapped>>> | |
368 | 345 | using ordered_value_multimap = multimap<_tKey, _tMapped, _fComp, _tAlloc>; |
369 | 346 | # endif |
370 | 347 |
@@ -384,12 +361,12 @@ | ||
384 | 361 | |
385 | 362 | template<typename _tKey, typename _tMapped, typename _fComp |
386 | 363 | = ystdex::less<_tKey>, class _tAlloc |
387 | - = default_allocator<std::pair<const _tKey, _tMapped>>> | |
364 | + = default_allocator<pair<const _tKey, _tMapped>>> | |
388 | 365 | using ordered_linked_map = map<_tKey, _tMapped, _fComp, _tAlloc>; |
389 | 366 | |
390 | 367 | template<typename _tKey, typename _tMapped, typename _fComp |
391 | 368 | = ystdex::less<_tKey>, class _tAlloc |
392 | - = default_allocator<std::pair<const _tKey, _tMapped>>> | |
369 | + = default_allocator<pair<const _tKey, _tMapped>>> | |
393 | 370 | using ordered_linked_multimap = multimap<_tKey, _tMapped, _fComp, _tAlloc>; |
394 | 371 | |
395 | 372 | template<typename _tKey, typename _fComp = ystdex::less<_tKey>, |
@@ -665,8 +642,6 @@ | ||
665 | 642 | namespace platform_ex |
666 | 643 | { |
667 | 644 | |
668 | -//! \since build 843 | |
669 | -using namespace platform::basic_utilities; | |
670 | 645 | //! \since build 593 |
671 | 646 | using namespace platform::containers; |
672 | 647 | //! \since build 843 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2014-2016, 2021, 2023 FrankHB. | |
2 | + © 2014-2016, 2021, 2023-2024 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -12,13 +12,13 @@ | ||
12 | 12 | \ingroup YCLib |
13 | 13 | \ingroup YCLibLimitedPlatforms |
14 | 14 | \brief Java 本机接口包装。 |
15 | -\version r307 | |
15 | +\version r309 | |
16 | 16 | \author FrankHB <frankhb1989@gmail.com> |
17 | 17 | \since build 552 |
18 | 18 | \par 创建时间: |
19 | 19 | 2014-11-11 03:20:32 +0800 |
20 | 20 | \par 修改时间: |
21 | - 2023-07-23 23:01 +0800 | |
21 | + 2024-02-26 23:01 +0800 | |
22 | 22 | \par 文本编码: |
23 | 23 | UTF-8 |
24 | 24 | \par 模块名称: |
@@ -34,7 +34,7 @@ | ||
34 | 34 | #if YF_Use_JNI |
35 | 35 | # include YFM_YCLib_Reference // for ystdex::remove_pointer_t, lref; |
36 | 36 | # include <jni.h> // for ::JavaVM, ::JNIEnv; |
37 | -# include YFM_YCLib_Container // for pair; | |
37 | +# include YFM_YCLib_Basic // for pair; | |
38 | 38 | # include YFM_YBaseMacro // for DefGetter; |
39 | 39 | # include <stdexcept> |
40 | 40 | # include <utility> |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2014-2016 FrankHB. | |
2 | + © 2014-2016, 2024 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file Mutex.h |
12 | 12 | \ingroup YCLib |
13 | 13 | \brief 互斥量。 |
14 | -\version r164 | |
14 | +\version r170 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 551 |
17 | 17 | \par 创建时间: |
18 | 18 | 2014-11-04 05:17:14 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2016-09-01 00:08 +0800 | |
20 | + 2024-02-26 00:59 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -29,7 +29,7 @@ | ||
29 | 29 | #define YCL_INC_Mutex_h_ 1 |
30 | 30 | |
31 | 31 | #include "YModules.h" |
32 | -#include YFM_YCLib_YCommon | |
32 | +#include YFM_YCLib_Platform // for YF_Multithread; | |
33 | 33 | #include <ystdex/type_op.hpp> // for ystdex::cond_or_t, ystdex::or_, |
34 | 34 | // std::is_integral, std::is_pointer; |
35 | 35 | #if YF_Multithread == 1 |
@@ -76,7 +76,7 @@ | ||
76 | 76 | //! \since build 723 |
77 | 77 | using ystdex::threading::shared_lockable_adaptor; |
78 | 78 | //! \since build 722 |
79 | -//@{ | |
79 | +//!@{ | |
80 | 80 | #if YF_Multithread == 1 || !defined(NDEBUG) |
81 | 81 | yconstfn bool UseLockDebug(true); |
82 | 82 | #else |
@@ -88,7 +88,7 @@ | ||
88 | 88 | template<class _tMutex> |
89 | 89 | using shared_lock_guard = ystdex::threading::lock_guard<_tMutex, |
90 | 90 | UseLockDebug, shared_lockable_adaptor<_tMutex>>; |
91 | -//@} | |
91 | +//!@} | |
92 | 92 | |
93 | 93 | using YCL_Impl_Ns_Mutex::lock; |
94 | 94 | using YCL_Impl_Ns_Mutex::try_lock; |
@@ -100,7 +100,7 @@ | ||
100 | 100 | |
101 | 101 | |
102 | 102 | //! \since build 723 |
103 | -//@{ | |
103 | +//!@{ | |
104 | 104 | template<class _type, typename _tReference = ystdex::lref<_type>> |
105 | 105 | using AdaptedLock = ystdex::threading::lock_base<_type, UseLockDebug, |
106 | 106 | lockable_adaptor<_type, _tReference>>; |
@@ -131,7 +131,7 @@ | ||
131 | 131 | template<class _type> |
132 | 132 | using SharedIndirectLockGuard |
133 | 133 | = SharedAdaptedLockGuard<_type, ystdex::indirect_ref_adaptor<_type>>; |
134 | -//@} | |
134 | +//!@} | |
135 | 135 | |
136 | 136 | } // namespace Concurrency; |
137 | 137 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2009-2016, 2018-2022 FrankHB. | |
2 | + © 2009-2016, 2018-2024 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file Platform.h |
12 | 12 | \ingroup YCLib |
13 | 13 | \brief 通用平台描述文件。 |
14 | -\version r864 | |
14 | +\version r907 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since 早于 build 132 |
17 | 17 | \par 创建时间: |
18 | 18 | 2009-11-24 00:05:08 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-11-28 19:57 +0800 | |
20 | + 2024-02-26 01:12 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -28,8 +28,7 @@ | ||
28 | 28 | #ifndef YCL_INC_Platform_h_ |
29 | 29 | #define YCL_INC_Platform_h_ 1 |
30 | 30 | |
31 | -#include <ystdex/cstddef.h> // for ystdex::byte, ystdex::octet, | |
32 | -// ystdex::ptrdiff_t, ystdex::size_t, ystdex::nullptr_t; | |
31 | +#include <ydef.h> | |
33 | 32 | |
34 | 33 | /*! |
35 | 34 | \def YF_DLL |
@@ -124,7 +123,7 @@ | ||
124 | 123 | \note 只保证不同的目标平台值为不同的非零整数。具体值可能随版本不同变动。 |
125 | 124 | \since build 458 |
126 | 125 | */ |
127 | -//@{ | |
126 | +//!@{ | |
128 | 127 | /*! |
129 | 128 | \brief DS 平台。 |
130 | 129 | */ |
@@ -216,9 +215,9 @@ | ||
216 | 215 | // TODO: Precise architecture detection. |
217 | 216 | # define YF_Platform YF_Platform_Android_ARM |
218 | 217 | #elif defined(__linux__) |
219 | -# ifdef __i386__ | |
218 | +# ifdef __x86_64__ | |
220 | 219 | # define YF_Platform YF_Platform_Linux_x64 |
221 | -# elif defined(__x86_64__) | |
220 | +# elif defined(__i386__) | |
222 | 221 | # define YF_Platform YF_Platform_Linux_x86 |
223 | 222 | # endif |
224 | 223 | #elif defined(__APPLE__) |
@@ -231,11 +230,11 @@ | ||
231 | 230 | //当前默认以 DS 作为目标平台。 |
232 | 231 | # define YF_Platform YF_Platform_DS |
233 | 232 | #endif |
234 | -//@} | |
233 | +//!@} | |
235 | 234 | |
236 | 235 | |
237 | 236 | //! \since build 553 |
238 | -//@{ | |
237 | +//!@{ | |
239 | 238 | /*! |
240 | 239 | \ingroup PlatformAPI |
241 | 240 | \def YCL_API_POSIXFileSystem |
@@ -267,7 +266,7 @@ | ||
267 | 266 | \note 当前仅支持 \c posix 线程模型 G++ 。 |
268 | 267 | \see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11953 。 |
269 | 268 | */ |
270 | -//@} | |
269 | +//!@} | |
271 | 270 | |
272 | 271 | /*! |
273 | 272 | \ingroup PlatformOptionalFeatures |
@@ -332,6 +331,9 @@ | ||
332 | 331 | #if YF_Platform == YF_Platform_DS |
333 | 332 | # define YCL_DS 1 |
334 | 333 | # define YF_Hosted 0 |
334 | +// NOTE: The platform %DS does not conforms to POSIX, but there are many APIs | |
335 | +// largely compliant to POSIX.1. However, there are subtle differences not | |
336 | +// conforming to POSIX, see Docuemntation::YCLib. | |
335 | 337 | # define YCL_API_POSIXFileSystem 1 |
336 | 338 | # define YCL_API_Has_dirent_h 1 |
337 | 339 | # define YCL_API_Has_unistd_h 1 |
@@ -415,45 +417,5 @@ | ||
415 | 417 | # define YF_Multithread 0 |
416 | 418 | #endif |
417 | 419 | |
418 | -/*! \defgroup TopLevelPlatformNamespaces Top-level Platform Namespaces | |
419 | -\brief 顶级平台命名空间。 | |
420 | -\since build 652 | |
421 | -*/ | |
422 | - | |
423 | -//! \ingroup TopLevelPlatformNamespaces | |
424 | -namespace platform | |
425 | -{ | |
426 | - | |
427 | -//! \since build 593 | |
428 | -inline namespace basic_types | |
429 | -{ | |
430 | - | |
431 | -/*! | |
432 | -\brief 平台通用数据类型。 | |
433 | -\since build 209 | |
434 | -*/ | |
435 | -//@{ | |
436 | -//! \since build 417 | |
437 | -using ystdex::byte; | |
438 | -//! \since build 417 | |
439 | -using ystdex::octet; | |
440 | -using ystdex::ptrdiff_t; | |
441 | -using ystdex::size_t; | |
442 | -//! \since build 644 | |
443 | -using ystdex::nullptr_t; | |
444 | -//@} | |
445 | - | |
446 | -} // inline namespace basic_types; | |
447 | - | |
448 | -} // namespace platform; | |
449 | - | |
450 | -//! \ingroup TopLevelPlatformNamespaces | |
451 | -namespace platform_ex | |
452 | -{ | |
453 | - | |
454 | -using namespace platform::basic_types; | |
455 | - | |
456 | -} // namespace platform_ex; | |
457 | - | |
458 | 420 | #endif |
459 | 421 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2012-2014 FrankHB. | |
2 | + © 2012-2014, 2024 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file Timer.h |
12 | 12 | \ingroup YCLib |
13 | 13 | \brief 平台相关的计时器接口。 |
14 | -\version r100 | |
14 | +\version r103 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 313 |
17 | 17 | \par 创建时间: |
18 | 18 | 2012-06-01 14:42:34 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2014-11-21 12:50 +0800 | |
20 | + 2024-02-26 01:03 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -29,7 +29,8 @@ | ||
29 | 29 | #define YCL_INC_Timer_h_ 1 |
30 | 30 | |
31 | 31 | #include "YModules.h" |
32 | -#include YFM_YCLib_YCommon | |
32 | +#include YFM_YCLib_Platform | |
33 | +#include <cstdint> // for std::uint32_t, std::uint64_t; | |
33 | 34 | |
34 | 35 | namespace platform |
35 | 36 | { |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2014-2015, 2018, 2021-2022 FrankHB. | |
2 | + © 2014-2015, 2018, 2021-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -12,13 +12,13 @@ | ||
12 | 12 | \ingroup YCLib |
13 | 13 | \ingroup YCLibLimitedPlatforms |
14 | 14 | \brief XCB GUI 接口。 |
15 | -\version r414 | |
15 | +\version r468 | |
16 | 16 | \author FrankHB <frankhb1989@gmail.com> |
17 | 17 | \since build 560 |
18 | 18 | \par 创建时间: |
19 | 19 | 2014-12-14 14:40:34 +0800 |
20 | 20 | \par 修改时间: |
21 | - 2022-01-25 05:02 +0800 | |
21 | + 2023-12-20 20:15 +0800 | |
22 | 22 | \par 文本编码: |
23 | 23 | UTF-8 |
24 | 24 | \par 模块名称: |
@@ -33,19 +33,18 @@ | ||
33 | 33 | #include YFM_YCLib_Platform |
34 | 34 | #if YF_Use_XCB |
35 | 35 | // #include <xcb/xcb.h> |
36 | -# include YFM_YCLib_Host // for platform::string_view, | |
37 | -// platform_ex::Exception; | |
38 | -# include <ystdex/base.h> // for ystdex::noncopyable, ystdex::nonmovable; | |
36 | +# include YFM_YCLib_Host // for string_view, std::uint8_t, noncopyable, | |
37 | +// nonmovable, string, platform_ex::Exception; | |
39 | 38 | # include YFM_YCLib_Debug // for platform::Deref; |
40 | -# include YFM_YSLib_Core_YGraphics | |
41 | -# include <atomic> | |
39 | +# include YFM_YSLib_Core_YGraphics // for YSLib::Drawing::Rect, | |
40 | +// YSLib::Drawing::Point, YSLib::Drawing::Size, YSLib::Drawing::ConstGraphics; | |
42 | 41 | |
43 | 42 | //! \since build 560 |
44 | -//@{ | |
43 | +//!@{ | |
45 | 44 | struct xcb_connection_t; |
46 | 45 | struct xcb_auth_info_t; |
47 | 46 | struct xcb_setup_t; |
48 | -//@} | |
47 | +//!@} | |
49 | 48 | //! \since build 561 |
50 | 49 | struct xcb_screen_t; |
51 | 50 |
@@ -56,29 +55,26 @@ | ||
56 | 55 | namespace XCB |
57 | 56 | { |
58 | 57 | |
59 | -//! \since build 659 | |
60 | -using platform::string_view; | |
61 | - | |
62 | 58 | //! \brief XCB 异常。 |
63 | 59 | class YF_API XCBException : public Exception |
64 | 60 | { |
65 | 61 | private: |
66 | 62 | //! \since build 561 |
67 | - //@{ | |
63 | + //!@{ | |
68 | 64 | std::uint8_t error_code; |
69 | 65 | std::uint16_t sequence; |
70 | 66 | std::uint32_t resource_id; |
71 | 67 | std::uint16_t minor_code; |
72 | 68 | std::uint8_t major_code; |
73 | 69 | std::uint32_t full_sequence; |
74 | - //@} | |
70 | + //!@} | |
75 | 71 | |
76 | 72 | public: |
77 | 73 | /*! |
78 | 74 | \pre 间接断言:字符串参数对应的数据指针非空。 |
79 | 75 | \since build 659 |
80 | 76 | */ |
81 | - //@{ | |
77 | + //!@{ | |
82 | 78 | YB_NONNULL(2) |
83 | 79 | XCBException(const char*, std::uint8_t, std::uint8_t, std::uint16_t, |
84 | 80 | std::uint32_t, std::uint16_t, std::uint8_t, std::uint32_t, |
@@ -86,7 +82,7 @@ | ||
86 | 82 | XCBException(string_view, std::uint8_t, std::uint8_t, std::uint16_t, |
87 | 83 | std::uint32_t, std::uint16_t, std::uint8_t, std::uint32_t, |
88 | 84 | YSLib::RecordLevel = YSLib::Emergent); |
89 | - //@} | |
85 | + //!@} | |
90 | 86 | //! \since build 845 |
91 | 87 | DefDeCopyCtor(XCBException) |
92 | 88 | /*! |
@@ -99,16 +95,22 @@ | ||
99 | 95 | DefDeCopyAssignment(XCBException) |
100 | 96 | |
101 | 97 | //! \since build 561 |
102 | - //@{ | |
103 | - DefGetter(const ynothrow, std::uint8_t, ErrorCode, error_code) | |
104 | - DefGetter(const ynothrow, std::uint8_t, FullSequence, full_sequence) | |
105 | - DefGetter(const ynothrow, std::uint8_t, MajorCode, major_code) | |
106 | - DefGetter(const ynothrow, std::uint16_t, MinorCode, minor_code) | |
107 | - DefGetter(const ynothrow, std::uint8_t, ResponseType, | |
98 | + //!@{ | |
99 | + YB_ATTR_nodiscard | |
100 | + DefGetter(const ynothrow, std::uint8_t, ErrorCode, error_code) | |
101 | + YB_ATTR_nodiscard | |
102 | + DefGetter(const ynothrow, std::uint8_t, FullSequence, full_sequence) | |
103 | + YB_ATTR_nodiscard | |
104 | + DefGetter(const ynothrow, std::uint8_t, MajorCode, major_code) | |
105 | + YB_ATTR_nodiscard | |
106 | + DefGetter(const ynothrow, std::uint16_t, MinorCode, minor_code) | |
107 | + YB_ATTR_nodiscard DefGetter(const ynothrow, std::uint8_t, ResponseType, | |
108 | 108 | std::uint8_t(code().value())) |
109 | - DefGetter(const ynothrow, std::uint32_t, ResourceID, resource_id) | |
110 | - DefGetter(const ynothrow, std::uint16_t, Sequence, sequence) | |
111 | - //@} | |
109 | + YB_ATTR_nodiscard | |
110 | + DefGetter(const ynothrow, std::uint32_t, ResourceID, resource_id) | |
111 | + YB_ATTR_nodiscard | |
112 | + DefGetter(const ynothrow, std::uint16_t, Sequence, sequence) | |
113 | + //!@} | |
112 | 114 | }; |
113 | 115 | |
114 | 116 |
@@ -125,10 +127,10 @@ | ||
125 | 127 | using tidy_ptr<::xcb_connection_t>::tidy_ptr; |
126 | 128 | DefDeCopyMoveCtorAssignment(ConnectionReference) |
127 | 129 | |
128 | - //! \pre 间接断言: \c bool(*this) 。 | |
129 | - //@{ | |
130 | + //! \pre 间接断言:\c bool(*this) 。 | |
131 | + //!@{ | |
130 | 132 | //! \brief 检查是否出现不可恢复的错误。 |
131 | - DefPred(const ynothrow, OnError, GetError() != 0) | |
133 | + YB_ATTR_nodiscard DefPred(const ynothrow, OnError, GetError() != 0) | |
132 | 134 | |
133 | 135 | /*! |
134 | 136 | \brief 取可能出现的不可恢复的错误。 |
@@ -158,7 +160,7 @@ | ||
158 | 160 | //! \brief 生成标识(用于创建窗口等)。 |
159 | 161 | std::uint32_t |
160 | 162 | GenerateID() const ynothrow; |
161 | - //@} | |
163 | + //!@} | |
162 | 164 | |
163 | 165 | //! \since build 845 |
164 | 166 | using tidy_ptr<::xcb_connection_t>::get; |
@@ -170,7 +172,7 @@ | ||
170 | 172 | \invariant \c get(*this) 。 |
171 | 173 | */ |
172 | 174 | class YF_API Connection final : private ConnectionReference, |
173 | - private ystdex::noncopyable, private ystdex::nonmovable | |
175 | + private noncopyable, private nonmovable | |
174 | 176 | { |
175 | 177 | private: |
176 | 178 | //! \since build 593 |
@@ -178,7 +180,7 @@ | ||
178 | 180 | |
179 | 181 | public: |
180 | 182 | //! \throw Exception 连接失败。 |
181 | - //@{ | |
183 | + //!@{ | |
182 | 184 | /*! |
183 | 185 | \brief 构造:使用显示名称和屏幕编号。 |
184 | 186 | \note 直接传递至 \c ::xcb_connect 。 |
@@ -197,11 +199,11 @@ | ||
197 | 199 | */ |
198 | 200 | explicit |
199 | 201 | Connection(ConnectionReference); |
200 | - //@} | |
202 | + //!@} | |
201 | 203 | //! \brief 析构:调用 \c ::xcb_disconnect 释放资源。 |
202 | 204 | ~Connection(); |
203 | 205 | |
204 | - DefBoolNeg(explicit, !IsOnError()) | |
206 | + YB_ATTR_nodiscard DefBoolNeg(YB_ATTR_nodiscard explicit, !IsOnError()) | |
205 | 207 | |
206 | 208 | using ConnectionReference::IsOnError; |
207 | 209 |
@@ -237,7 +239,7 @@ | ||
237 | 239 | explicit |
238 | 240 | Atom(::xcb_connection_t&, string_view, bool = {}) ynothrowv; |
239 | 241 | |
240 | - DefCvt(const ynothrow, NativeType, atom) | |
242 | + YB_ATTR_nodiscard DefCvt(const ynothrow, NativeType, atom) | |
241 | 243 | }; |
242 | 244 | |
243 | 245 |
@@ -247,7 +249,7 @@ | ||
247 | 249 | \since build 563 |
248 | 250 | */ |
249 | 251 | YF_API Atom::NativeType |
250 | -LookupAtom(::xcb_connection_t&, const YSLib::string&); | |
252 | +LookupAtom(::xcb_connection_t&, const string&); | |
251 | 253 | |
252 | 254 | |
253 | 255 | /*! |
@@ -274,8 +276,9 @@ | ||
274 | 276 | DefDeDtor(Drawable) |
275 | 277 | |
276 | 278 | public: |
277 | - DefGetter(const ynothrow, ConnectionReference, ConnectionRef, conn_ref) | |
278 | - DefGetter(const ynothrow, ID, ID, id) | |
279 | + YB_ATTR_nodiscard | |
280 | + DefGetter(const ynothrow, ConnectionReference, ConnectionRef, conn_ref) | |
281 | + YB_ATTR_nodiscard DefGetter(const ynothrow, ID, ID, id) | |
279 | 282 | |
280 | 283 | PDefH(::xcb_connection_t&, DerefConn, ) const ynothrow |
281 | 284 | ImplRet(platform::Deref(conn_ref.get())) |
@@ -290,7 +293,7 @@ | ||
290 | 293 | \throw Exception 连接失败。 |
291 | 294 | \since build 563 |
292 | 295 | */ |
293 | - //@{ | |
296 | + //!@{ | |
294 | 297 | /*! |
295 | 298 | \brief 使用指定连接、边界矩形,以默认屏幕根节点作为父窗口。 |
296 | 299 | \exception Exception 找不到 XCB 连接设定。 |
@@ -302,7 +305,7 @@ | ||
302 | 305 | const ::xcb_screen_t&); |
303 | 306 | //! \brief 使用指定连接、边界矩形和父窗口 ID 。 |
304 | 307 | WindowData(::xcb_connection_t&, const YSLib::Drawing::Rect&, ID); |
305 | - //@} | |
308 | + //!@} | |
306 | 309 | /*! |
307 | 310 | \brief 析构:销毁窗口。 |
308 | 311 | \since build 845 |
@@ -310,15 +313,17 @@ | ||
310 | 313 | ~WindowData(); |
311 | 314 | |
312 | 315 | //! \since build 562 |
313 | - //@{ | |
316 | + //!@{ | |
314 | 317 | YSLib::Drawing::Rect |
315 | 318 | GetBounds() const; |
316 | - DefGetter(const, YSLib::Drawing::Point, Location, GetBounds().GetPoint()) | |
317 | - DefGetter(const, YSLib::Drawing::Size, Size, GetBounds().GetSize()) | |
319 | + YB_ATTR_nodiscard DefGetter(const, YSLib::Drawing::Point, Location, | |
320 | + GetBounds().GetPoint()) | |
321 | + YB_ATTR_nodiscard | |
322 | + DefGetter(const, YSLib::Drawing::Size, Size, GetBounds().GetSize()) | |
318 | 323 | |
319 | 324 | void |
320 | 325 | SetBounds(const YSLib::Drawing::Rect&); |
321 | - //@} | |
326 | + //!@} | |
322 | 327 | |
323 | 328 | //! \since build 562 |
324 | 329 | void |
@@ -328,14 +333,14 @@ | ||
328 | 333 | Hide(); |
329 | 334 | |
330 | 335 | //! \since build 562 |
331 | - //@{ | |
336 | + //!@{ | |
332 | 337 | PDefH(void, Invalidate, ) |
333 | 338 | ImplExpr(Invalidate(GetBounds())) |
334 | 339 | void |
335 | 340 | Invalidate(const YSLib::Drawing::Rect&); |
336 | 341 | |
337 | 342 | //! \since build 563 |
338 | - PDefH(Atom::NativeType, LookupAtom, const YSLib::string& name) | |
343 | + PDefH(Atom::NativeType, LookupAtom, const string& name) | |
339 | 344 | ImplRet(XCB::LookupAtom(DerefConn(), name)) |
340 | 345 | |
341 | 346 | void |
@@ -346,7 +351,7 @@ | ||
346 | 351 | |
347 | 352 | void |
348 | 353 | Show(); |
349 | - //@} | |
354 | + //!@} | |
350 | 355 | }; |
351 | 356 | |
352 | 357 |
@@ -354,7 +359,7 @@ | ||
354 | 359 | \brief 图形上下文。 |
355 | 360 | \since build 563 |
356 | 361 | */ |
357 | -class YF_API GContext final : public Drawable, private YSLib::noncopyable | |
362 | +class YF_API GContext final : public Drawable, private noncopyable | |
358 | 363 | { |
359 | 364 | public: |
360 | 365 | GContext(::xcb_connection_t& c_ref) ynothrow |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2009-2016, 2018-2023 FrankHB. | |
2 | + © 2009-2016, 2018-2024 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file YCommon.h |
12 | 12 | \ingroup YCLib |
13 | 13 | \brief 平台相关的公共组件无关函数与宏定义集合。 |
14 | -\version r4160 | |
14 | +\version r4165 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 561 |
17 | 17 | \par 创建时间: |
18 | 18 | 2009-11-12 22:14:28 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2023-04-05 12:47 +0800 | |
20 | + 2024-02-25 22:06 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -41,7 +41,7 @@ | ||
41 | 41 | #include <ystdex/cstring.h> // for ystdex::uchar_t, ystdex::replace_cast; |
42 | 42 | #include YFM_YBaseMacro // for TryRet, CatchIgnore; |
43 | 43 | #include <exception> // for std::bad_alloc; |
44 | -#include YFM_YCLib_Container // for pair, vector, string; | |
44 | +#include YFM_YCLib_Container // for vector, string, pair; | |
45 | 45 | |
46 | 46 | //! \brief 默认平台命名空间。 |
47 | 47 | namespace platform |
@@ -64,8 +64,8 @@ | ||
64 | 64 | {}; |
65 | 65 | |
66 | 66 | #if YB_IMPL_CLANGPP |
67 | -# pragma clang diagnostic push | |
68 | -# pragma clang diagnostic ignored "-Wweak-vtables" | |
67 | + YB_Diag_Push | |
68 | + YB_Diag_Ignore(weak-vtables) | |
69 | 69 | #endif |
70 | 70 | |
71 | 71 | //! \brief 宿主平台标识的公共标记类型:指定任意宿主平台。 |
@@ -116,7 +116,7 @@ | ||
116 | 116 | #define YCL_Tag_constfn inline |
117 | 117 | |
118 | 118 | #if YB_IMPL_CLANGPP |
119 | -# pragma clang diagnostic pop | |
119 | + YB_Diag_Pop | |
120 | 120 | #endif |
121 | 121 | |
122 | 122 | /*! |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2013-2015 FrankHB. | |
2 | + © 2013-2015, 2024 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -21,13 +21,13 @@ | ||
21 | 21 | /*! \file YModules.h |
22 | 22 | \ingroup YCLib |
23 | 23 | \brief YCLib 库模块配置文件。 |
24 | -\version r106 | |
24 | +\version r121 | |
25 | 25 | \author FrankHB <frankhb1989@gmail.com> |
26 | 26 | \since build 462 |
27 | 27 | \par 创建时间: |
28 | 28 | 2013-12-23 21:57:20 +0800 |
29 | 29 | \par 修改时间: |
30 | - 2015-09-12 19:56 +0800 | |
30 | + 2024-02-25 21:53 +0800 | |
31 | 31 | \par 文本编码: |
32 | 32 | UTF-8 |
33 | 33 | \par 模块名称: |
@@ -41,10 +41,18 @@ | ||
41 | 41 | #include "../YModules.h" |
42 | 42 | |
43 | 43 | //! \since build 461 |
44 | -//@{ | |
44 | +//!@{ | |
45 | 45 | #define YFM_YCLib_Platform <YCLib/Platform.h> |
46 | +#define YFM_YCLib_NativeAPI <YCLib/NativeAPI.h> | |
47 | +//! \since build 982 | |
48 | +#define YFM_YCLib_Basic <YCLib/Basic.h> | |
49 | +//! \since build 593 | |
50 | +#define YFM_YCLib_Reference <YCLib/Reference.h> | |
51 | +//! \since build 593 | |
52 | +#define YFM_YCLib_Container <YCLib/Container.h> | |
53 | +//! \since build 551 | |
54 | +#define YFM_YCLib_Mutex <YCLib/Mutex.h> | |
46 | 55 | #define YFM_YCLib_YCommon <YCLib/YCommon.h> |
47 | -#define YFM_YCLib_NativeAPI <YCLib/NativeAPI.h> | |
48 | 56 | #define YFM_YCLib_Debug <YCLib/Debug.h> |
49 | 57 | //! \since build 615 |
50 | 58 | #define YFM_YCLib_FileIO <YCLib/FileIO.h> |
@@ -54,12 +62,6 @@ | ||
54 | 62 | #define YFM_YCLib_Keys <YCLib/Keys.h> |
55 | 63 | #define YFM_YCLib_Input <YCLib/Input.h> |
56 | 64 | #define YFM_YCLib_MemoryMapping <YCLib/MemoryMapping.h> |
57 | -//! \since build 593 | |
58 | -#define YFM_YCLib_Container <YCLib/Container.h> | |
59 | -//! \since build 551 | |
60 | -#define YFM_YCLib_Mutex <YCLib/Mutex.h> | |
61 | -//! \since build 593 | |
62 | -#define YFM_YCLib_Reference <YCLib/Reference.h> | |
63 | 65 | |
64 | 66 | //! \since build 492 |
65 | 67 | #define YFM_YCLib_Host <YCLib/Host.h> |
@@ -76,16 +78,16 @@ | ||
76 | 78 | #define YFM_DS_YCLib_DSVideo <YCLib/DSVideo.h> |
77 | 79 | //! \since build 604 |
78 | 80 | #define YFM_DS_YCLib_DSIO <YCLib/DSIO.h> |
79 | -//@} | |
81 | +//!@} | |
80 | 82 | |
81 | 83 | //! \since build 633 |
82 | -//@{ | |
84 | +//!@{ | |
83 | 85 | #define YFM_Win32_YCLib_MinGW32 <YCLib/MinGW32.h> |
84 | 86 | #define YFM_Win32_YCLib_Registry <YCLib/Registry.h> |
85 | 87 | #define YFM_Win32_YCLib_COM <YCLib/COM.h> |
86 | 88 | #define YFM_Win32_YCLib_NLS <YCLib/NLS.h> |
87 | 89 | #define YFM_Win32_YCLib_Consoles <YCLib/Consoles.h> |
88 | -//@} | |
90 | +//!@} | |
89 | 91 | //! \since build 492 |
90 | 92 | #define YFM_Android_YCLib_Android <YCLib/Android.h> |
91 | 93 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2010-2023 FrankHB. | |
2 | + © 2010-2024 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file YAdaptor.h |
12 | 12 | \ingroup Adaptor |
13 | 13 | \brief 外部库关联。 |
14 | -\version r2571 | |
14 | +\version r2612 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since 早于 build 132 |
17 | 17 | \par 创建时间: |
18 | 18 | 2010-02-22 20:16:21 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2023-10-13 01:07 +0800 | |
20 | + 2024-02-24 10:35 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -77,6 +77,13 @@ | ||
77 | 77 | using namespace platform::references; |
78 | 78 | //!@} |
79 | 79 | |
80 | +//! \since build 650 | |
81 | +using ystdex::_t; | |
82 | + | |
83 | +//! \since build 939 | |
84 | +using ystdex::trivial_swap; | |
85 | +//! \since build 939 | |
86 | +using ystdex::trivial_swap_t; | |
80 | 87 | |
81 | 88 | //! \note 替代较新版本的 std 对应接口,以不被当前实现模式支持的旧版 std 限制。 |
82 | 89 | //!@{ |
@@ -100,6 +107,33 @@ | ||
100 | 107 | using platform::wstring_view; |
101 | 108 | //!@} |
102 | 109 | //!@} |
110 | +//! \since build 836 | |
111 | +using platform::string_view_t; | |
112 | + | |
113 | +// !\note 可能使用 ADL 。 | |
114 | +//!@{ | |
115 | +//! \since build 861 | |
116 | +using ystdex::make_string_view; | |
117 | + | |
118 | +//! \since build 896 | |
119 | +using platform::to_pmr_string; | |
120 | +//! \since build 861 | |
121 | +using platform::to_std_string; | |
122 | + | |
123 | +//! \since build 593 | |
124 | +using platform::to_string; | |
125 | +//! \since build 593 | |
126 | +using platform::to_wstring; | |
127 | +//!@} | |
128 | + | |
129 | +/*! | |
130 | +\note 假定不使用 ADL 。 | |
131 | +\since build 593 | |
132 | +*/ | |
133 | +//!@{ | |
134 | +using platform::sfmt; | |
135 | +using platform::vsfmt; | |
136 | +//!@} | |
103 | 137 | |
104 | 138 | /*! |
105 | 139 | \note 替代标准库的类模板和类。 |
@@ -133,45 +167,6 @@ | ||
133 | 167 | //!@} |
134 | 168 | |
135 | 169 | |
136 | -//! \since build 650 | |
137 | -using ystdex::_t; | |
138 | -//! \since build 209 | |
139 | -using ystdex::noncopyable; | |
140 | -//! \since build 373 | |
141 | -using ystdex::nonmovable; | |
142 | - | |
143 | -//! \since build 939 | |
144 | -using ystdex::trivial_swap; | |
145 | -//! \since build 939 | |
146 | -using ystdex::trivial_swap_t; | |
147 | - | |
148 | -//! \since build 836 | |
149 | -using platform::string_view_t; | |
150 | - | |
151 | -//! \since build 593 | |
152 | -//!@{ | |
153 | -//! \note 假定不使用 ADL 。 | |
154 | -//!@{ | |
155 | -using platform::sfmt; | |
156 | -using platform::vsfmt; | |
157 | -//!@} | |
158 | - | |
159 | -// !\note 可能使用 ADL 。 | |
160 | -//!@{ | |
161 | -//! \since build 861 | |
162 | -using ystdex::make_string_view; | |
163 | - | |
164 | -//! \since build 896 | |
165 | -using platform::to_pmr_string; | |
166 | -//! \since build 861 | |
167 | -using platform::to_std_string; | |
168 | - | |
169 | -using platform::to_string; | |
170 | -using platform::to_wstring; | |
171 | -//!@} | |
172 | -//!@} | |
173 | - | |
174 | - | |
175 | 170 | /*! |
176 | 171 | \brief 解锁删除器:使用线程模型对应的互斥量和锁。 |
177 | 172 | \since build 590 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2009-2016, 2018-2019, 2022 FrankHB. | |
2 | + © 2009-2016, 2018-2019, 2022-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file YApplication.h |
12 | 12 | \ingroup Core |
13 | 13 | \brief 系统资源和应用程序实例抽象。 |
14 | -\version r1802 | |
14 | +\version r1813 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 577 |
17 | 17 | \par 创建时间: |
18 | 18 | 2009-12-27 17:12:27 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-11-21 07:14 +0800 | |
20 | + 2023-12-20 20:17 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -91,7 +91,8 @@ | ||
91 | 91 | ~Application() override; |
92 | 92 | |
93 | 93 | //! \brief 取得线程空间中当前运行的 Shell 的句柄。 |
94 | - DefGetter(const ynothrow, shared_ptr<Shell>, ShellHandle, hShell) | |
94 | + YB_ATTR_nodiscard | |
95 | + DefGetter(const ynothrow, shared_ptr<Shell>, ShellHandle, hShell) | |
95 | 96 | |
96 | 97 | /*! |
97 | 98 | \brief 执行消息队列操作。 |
@@ -112,7 +113,7 @@ | ||
112 | 113 | \note 线程安全:全局互斥访问。 |
113 | 114 | \since build 693 |
114 | 115 | */ |
115 | - //@{ | |
116 | + //!@{ | |
116 | 117 | template<typename _tParam> |
117 | 118 | void |
118 | 119 | AddExit(_tParam&& arg) |
@@ -153,7 +154,7 @@ | ||
153 | 154 | return {YSLib::unchecked_any_cast<ystdex::decay_t<_tParam>>( |
154 | 155 | &on_exit.top()), std::move(lck)}; |
155 | 156 | } |
156 | - //@} | |
157 | + //!@} | |
157 | 158 | |
158 | 159 | /*! |
159 | 160 | \brief 处理消息:分发消息。 |
@@ -218,11 +219,12 @@ | ||
218 | 219 | /*! |
219 | 220 | \ingroup helper_functions |
220 | 221 | \brief 激活 Shell 对象:控制权转移给此对象以维持单线程运行。 |
221 | -\pre 断言: <tt>bool(hShl)</tt> 。 | |
222 | +\pre 断言:\c bool(h) 。 | |
222 | 223 | \warning 不保证线程安全性。 |
224 | +\since build 956 | |
223 | 225 | */ |
224 | -inline PDefH(bool, Activate, const shared_ptr<Shell>& hShl) | |
225 | - ImplRet(FetchAppInstance().Switch(shared_ptr<Shell>(hShl))) | |
226 | +inline PDefH(bool, Activate, shared_ptr<Shell> h) | |
227 | + ImplRet(FetchAppInstance().Switch(std::move(h))) | |
226 | 228 | |
227 | 229 | |
228 | 230 | /*! |
@@ -237,7 +239,7 @@ | ||
237 | 239 | \note 线程安全。 |
238 | 240 | \since build 550 |
239 | 241 | */ |
240 | -//@{ | |
242 | +//!@{ | |
241 | 243 | YF_API void |
242 | 244 | PostMessage(const Message&, Messaging::Priority); |
243 | 245 | inline PDefH(void, PostMessage, Messaging::ID id, Messaging::Priority prior, |
@@ -253,7 +255,7 @@ | ||
253 | 255 | { |
254 | 256 | PostMessage(_vID, prior, ValueObject(target)); |
255 | 257 | } |
256 | -//@} | |
258 | +//!@} | |
257 | 259 | |
258 | 260 | /*! |
259 | 261 | \brief 以指定错误码和优先级发起 Shell 终止请求。 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2009-2015, 2019-2022 FrankHB. | |
2 | + © 2009-2015, 2019-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file YDevice.h |
12 | 12 | \ingroup Core |
13 | 13 | \brief 平台无关的设备抽象层。 |
14 | -\version r2102 | |
14 | +\version r2110 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 586 |
17 | 17 | \par 创建时间: |
18 | 18 | 2009-12-28 16:39:39 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-11-28 19:57 +0800 | |
20 | + 2023-12-20 20:20 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -63,24 +63,24 @@ | ||
63 | 63 | virtual ~GraphicDevice(); |
64 | 64 | |
65 | 65 | //! \since build 319 |
66 | - //@{ | |
66 | + //!@{ | |
67 | 67 | using Graphics::operator!; |
68 | 68 | |
69 | 69 | using Graphics::operator bool; |
70 | - //@} | |
70 | + //!@} | |
71 | 71 | |
72 | 72 | /*! |
73 | 73 | \brief 取后备缓冲区。 |
74 | 74 | \since build 407 |
75 | 75 | */ |
76 | - virtual DefGetter(const, unique_ptr<Drawing::IImage>, BackBuffer, | |
77 | - unique_ptr<Drawing::IImage>()) | |
76 | + YB_ATTR_nodiscard virtual DefGetter(const, unique_ptr<Drawing::IImage>, | |
77 | + BackBuffer, unique_ptr<Drawing::IImage>()) | |
78 | 78 | //! \since build 296 |
79 | - //@{ | |
79 | + //!@{ | |
80 | 80 | using Graphics::GetHeight; |
81 | 81 | using Graphics::GetWidth; |
82 | 82 | using Graphics::GetSize; |
83 | - //@} | |
83 | + //!@} | |
84 | 84 | |
85 | 85 | //! \since build 558 |
86 | 86 | virtual DefSetter(, const Drawing::Size&, Size, sGraphics) |
@@ -113,7 +113,7 @@ | ||
113 | 113 | //! \brief 虚析构:类定义外默认实现。 |
114 | 114 | virtual ~KeyInputDevice(); |
115 | 115 | |
116 | - DefGetter(const ynothrow, KeyIndex, Width, width) | |
116 | + YB_ATTR_nodiscard DefGetter(const ynothrow, KeyIndex, Width, width) | |
117 | 117 | |
118 | 118 | //! \brief 按键映射。 |
119 | 119 | virtual PDefH(KeyIndex, Map, KeyIndex code) |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2010-2016, 2018-2022 FrankHB. | |
2 | + © 2010-2016, 2018-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file YException.h |
12 | 12 | \ingroup Core |
13 | 13 | \brief 异常处理模块。 |
14 | -\version r708 | |
14 | +\version r731 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 560 |
17 | 17 | \par 创建时间: |
18 | 18 | 2010-06-15 20:30:14 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-02-26 23:04 +0800 | |
20 | + 2023-12-20 20:21 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -41,7 +41,7 @@ | ||
41 | 41 | { |
42 | 42 | |
43 | 43 | //! \ingroup exceptions |
44 | -//@{ | |
44 | +//!@{ | |
45 | 45 | //! \brief 一般运行时异常事件类。 |
46 | 46 | using GeneralEvent = std::runtime_error; |
47 | 47 |
@@ -58,14 +58,14 @@ | ||
58 | 58 | \brief 构造:使用异常字符串和记录等级。 |
59 | 59 | \since build 643 |
60 | 60 | */ |
61 | - //@{ | |
61 | + //!@{ | |
62 | 62 | //! \pre 间接断言:第一参数非空。 |
63 | 63 | YB_NONNULL(2) |
64 | 64 | LoggedEvent(const char* = "", RecordLevel = Emergent); |
65 | 65 | //! \since build 921 |
66 | 66 | LoggedEvent(const std::string&, RecordLevel = Emergent); |
67 | 67 | LoggedEvent(const string_view, RecordLevel = Emergent); |
68 | - //@} | |
68 | + //!@} | |
69 | 69 | /*! |
70 | 70 | \brief 构造:使用一般异常事件对象和记录等级。 |
71 | 71 | \since build 624 |
@@ -80,7 +80,7 @@ | ||
80 | 80 | ~LoggedEvent() override; |
81 | 81 | |
82 | 82 | //! \since build 624 |
83 | - DefGetter(const ynothrow, RecordLevel, Level, level) | |
83 | + YB_ATTR_nodiscard DefGetter(const ynothrow, RecordLevel, Level, level) | |
84 | 84 | }; |
85 | 85 | |
86 | 86 |
@@ -117,10 +117,11 @@ | ||
117 | 117 | ~FatalError() override; |
118 | 118 | |
119 | 119 | //! \since build 646 |
120 | - DefGetter(const ynothrow, string_view, Content, Deref(content)) | |
121 | - DefGetter(const ynothrow, const char*, Title, what()) | |
120 | + YB_ATTR_nodiscard | |
121 | + DefGetter(const ynothrow, string_view, Content, Deref(content)) | |
122 | + YB_ATTR_nodiscard DefGetter(const ynothrow, const char*, Title, what()) | |
122 | 123 | }; |
123 | -//@} | |
124 | +//!@} | |
124 | 125 | |
125 | 126 | |
126 | 127 | /*! |
@@ -135,9 +136,9 @@ | ||
135 | 136 | |
136 | 137 | |
137 | 138 | //! \sa YF_TraceRaw |
138 | -//@{ | |
139 | +//!@{ | |
139 | 140 | //! \note 若抛出异常,放弃层次信息,通过 YF_TraceRaw 打印错误消息。 |
140 | -//@{ | |
141 | +//!@{ | |
141 | 142 | /*! |
142 | 143 | \brief 打印带有层次信息的需要保证无异常抛出的错误。 |
143 | 144 | \pre 间接断言:第二参数非空。 |
@@ -157,8 +158,8 @@ | ||
157 | 158 | */ |
158 | 159 | YF_API YB_NONNULL(1) void |
159 | 160 | PrintMessage(const char*, RecordLevel = Err, size_t level = 0) ynothrow; |
160 | -//@} | |
161 | -//@} | |
161 | +//!@} | |
162 | +//!@} | |
162 | 163 | |
163 | 164 | /*! |
164 | 165 | \brief 追踪记录异常类型。 |
@@ -171,7 +172,7 @@ | ||
171 | 172 | TraceExceptionType(const std::exception&, RecordLevel = Err) ynothrow; |
172 | 173 | |
173 | 174 | /*! |
174 | -\brief 使用 PrintMessage 展开和追踪异常类型和信息。 | |
175 | +\brief 使用 PrintMessage 提取和追踪异常类型和信息。 | |
175 | 176 | \sa ExtractException |
176 | 177 | \sa PrintMessage |
177 | 178 | \sa TraceExceptionType |
@@ -184,7 +185,7 @@ | ||
184 | 185 | ExtractAndTrace(const std::exception&, RecordLevel = Err) ynothrow; |
185 | 186 | |
186 | 187 | /*! |
187 | -\brief 展开指定层次的异常并使用指定参数记录。 | |
188 | +\brief 提取指定层次的异常并使用指定参数记录。 | |
188 | 189 | \sa PrintCriticalFor |
189 | 190 | \since build 888 |
190 | 191 | */ |
@@ -192,13 +193,13 @@ | ||
192 | 193 | ExtractException(const ExtractedLevelPrinter&, const std::exception&, |
193 | 194 | size_t = 0) ynothrow; |
194 | 195 | |
195 | -//! \return 是否发生并捕获异常。 | |
196 | -//@{ | |
197 | 196 | /*! |
198 | 197 | \brief 执行并尝试记录异常。 |
198 | +\return 是否捕获和记录了异常。 | |
199 | 199 | \since build 829 |
200 | 200 | |
201 | 201 | 对参数指定的函数求值,并使用最后一个参数追踪记录异常。 |
202 | +只捕获和记录 ExceptionTracer 可记录的异常,即匹配 \c std::exception 的异常。 | |
202 | 203 | */ |
203 | 204 | template<typename _func> |
204 | 205 | bool |
@@ -222,6 +223,7 @@ | ||
222 | 223 | |
223 | 224 | /*! |
224 | 225 | \brief 调用函数并尝试返回。 |
226 | +\return 不经异常退出的调用结果或异常退出时默认初始化的结果。 | |
225 | 227 | \since build 702 |
226 | 228 | */ |
227 | 229 | template<typename _fCallable, typename... _tParams> |
@@ -237,6 +239,7 @@ | ||
237 | 239 | /*! |
238 | 240 | \brief 调用函数并过滤宿主异常。 |
239 | 241 | \note 使用 ADL TryExecute 。 |
242 | +\return 是否发生并捕获异常。 | |
240 | 243 | \since build 624 |
241 | 244 | |
242 | 245 | 对参数指定的函数求值,并捕获和追踪记录所有异常。 |
@@ -249,10 +252,10 @@ | ||
249 | 252 | ExceptionTracer trace = ExtractAndTrace) ynothrow |
250 | 253 | { |
251 | 254 | return !TryInvoke([=]{ |
255 | + // NOTE: This may throw excpections not match a %std::exception handler. | |
252 | 256 | return !TryExecute(f, desc, lv, trace); |
253 | 257 | }); |
254 | 258 | } |
255 | -//@} | |
256 | 259 | |
257 | 260 | } // namespace YSLib; |
258 | 261 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2009-2022 FrankHB. | |
2 | + © 2009-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file File.h |
12 | 12 | \ingroup Service |
13 | 13 | \brief 平台中立的文件抽象。 |
14 | -\version r1697 | |
14 | +\version r1704 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 473 |
17 | 17 | \par 创建时间: |
18 | 18 | 2009-11-24 23:14:41 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-11-28 19:59 +0800 | |
20 | + 2023-12-20 20:22 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -65,7 +65,7 @@ | ||
65 | 65 | \throw std::system_error 文件存在且操作失败。 |
66 | 66 | \since build 713 |
67 | 67 | */ |
68 | -//@{ | |
68 | +//!@{ | |
69 | 69 | template<typename _tChar> |
70 | 70 | YB_NONNULL(1) void |
71 | 71 | Remove(const _tChar* path) |
@@ -93,11 +93,11 @@ | ||
93 | 93 | + IO::MakePathString(path) + '\'').c_str()); |
94 | 94 | } |
95 | 95 | } |
96 | -//@} | |
96 | +//!@} | |
97 | 97 | |
98 | 98 | |
99 | 99 | //! \since build 724 |
100 | -//@{ | |
100 | +//!@{ | |
101 | 101 | //! \brief 共享锁定的文件映射输入流。 |
102 | 102 | class YF_API SharedInputMappedFileStream : private MappedFile, |
103 | 103 | private SharedIndirectLockGuard<const UniqueFile>, private ystdex::membuf, |
@@ -141,7 +141,7 @@ | ||
141 | 141 | \pre 间接断言:指针参数非空。 |
142 | 142 | \since build 838 |
143 | 143 | */ |
144 | - //@{ | |
144 | + //!@{ | |
145 | 145 | /*! |
146 | 146 | \pre 指定打开模式的参数兼容。 |
147 | 147 | \note 为避免误用,打开模式不提供默认参数。 |
@@ -166,12 +166,12 @@ | ||
166 | 166 | std::ios_base::openmode mode, mode_t pmode = DefaultPMode()) |
167 | 167 | : UniqueLockedOutputFileStream(uopen(filename, {}, mode, pmode), mode) |
168 | 168 | {} |
169 | - //@} | |
169 | + //!@} | |
170 | 170 | |
171 | 171 | //! \brief 虚析构:类定义外默认实现。 |
172 | 172 | ~UniqueLockedOutputFileStream() override; |
173 | 173 | }; |
174 | -//@} | |
174 | +//!@} | |
175 | 175 | |
176 | 176 | } // namespace IO; |
177 | 177 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2010-2016, 2018-2023 FrankHB. | |
2 | + © 2010-2016, 2018-2024 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file FileSystem.h |
12 | 12 | \ingroup Service |
13 | 13 | \brief 平台中立的文件系统抽象。 |
14 | -\version r4073 | |
14 | +\version r4179 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 473 |
17 | 17 | \par 创建时间: |
18 | 18 | 2010-03-28 00:09:28 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2023-10-02 16:46 +0800 | |
20 | + 2024-02-25 02:13 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -35,7 +35,8 @@ | ||
35 | 35 | // std::is_convertible, std::is_constructible, u16string_view, |
36 | 36 | // std::enable_if_inconvertible_t, ystdex::enable_if_constructible_r_t, |
37 | 37 | // FetchCurrentWorkingDirectory, NodeCategory, IsDirectory, function, |
38 | -// FileDescriptor, mode_t, UniqueFile, IO::Remove; | |
38 | +// FileDescriptor, mode_t, UniqueFile, IO::Remove, MappedFile, | |
39 | +// std::throw_with_nested, GeneralEvent, std::string; | |
39 | 40 | #include <ystdex/path.hpp> // for ystdex::path, ystdex::to_string, |
40 | 41 | // ystdex::to_string_d; |
41 | 42 | #include YFM_YSLib_Core_YString // for String; |
@@ -702,11 +703,11 @@ | ||
702 | 703 | */ |
703 | 704 | template<class _tString> |
704 | 705 | inline ystdex::remove_cvref_t<_tString> |
705 | -VerifyDirectoryPathTail(_tString&& str) | |
706 | +VerifyDirectoryPathTail(_tString&& path) | |
706 | 707 | { |
707 | - if(!(str.empty() || VerifyDirectory(str))) | |
708 | - str.pop_back(); | |
709 | - return yforward(str); | |
708 | + if(!(path.empty() || VerifyDirectory(path))) | |
709 | + path.pop_back(); | |
710 | + return yforward(path); | |
710 | 711 | } |
711 | 712 | |
712 | 713 | /*! |
@@ -1110,12 +1111,124 @@ | ||
1110 | 1111 | YF_API NodeCategory |
1111 | 1112 | ClassifyNode(const Path&); |
1112 | 1113 | |
1114 | + | |
1115 | +/*! | |
1116 | +\brief 以参数指定的路径加载映射单元。 | |
1117 | +\throw GeneralEvent 嵌套异常:打开文件失败。 | |
1118 | +\since build 982 | |
1119 | +*/ | |
1120 | +template<typename _tParam, typename... _tParams> | |
1121 | +YB_ATTR_nodiscard MappedFile | |
1122 | +LoadMappedModule(_tParam&& path, _tParams&&... args) | |
1123 | +{ | |
1124 | + TryRet(MappedFile(yforward(args)...)) | |
1125 | + CatchExpr(..., std::throw_with_nested( | |
1126 | + GeneralEvent("Loading module '" + std::string(path) + "' failed."))) | |
1127 | + YAssert(false, "Unreachable control found."); | |
1128 | +} | |
1129 | + | |
1113 | 1130 | } // namespace IO; |
1114 | 1131 | |
1115 | 1132 | //! \since build 921 |
1116 | 1133 | namespace Deployment |
1117 | 1134 | { |
1118 | 1135 | |
1136 | +//! \since build 982 | |
1137 | +//!@{ | |
1138 | +/*! | |
1139 | +\brief 判断参数指示的位置是否符合局部 FHS 目录布局。 | |
1140 | +\see https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html 。 | |
1141 | + | |
1142 | +以 POSIX 环境变量语法,预期的局部用户目录布局为: | |
1143 | +$PREFIX/ | |
1144 | +$PREFIX/$BIN/ | |
1145 | +$PREFIX/lib/ | |
1146 | +$PREFIX/share/ | |
1147 | +其中,$PREFIX 为路径前缀,$BIN 是任意非空的目录名。 | |
1148 | +当参数指定 $PREFIX/$BIN/ 目录,且以上路径以目录存在时,检查通过。 | |
1149 | +假定检查目录时,布局不改变。 | |
1150 | +实现可分别检查各项路径,而不要求避免外部并发访问的竞争。 | |
1151 | +*/ | |
1152 | +//!@{ | |
1153 | +/*! | |
1154 | +\note 参数指定路径前缀和其中的 bin 目录。 | |
1155 | +\warning 假定前缀指定目录是根目录且第二参数是其子目录,不检查参数之间的关系。 | |
1156 | +*/ | |
1157 | +YB_ATTR_nodiscard YF_API YB_PURE bool | |
1158 | +CheckLocalFHSLayout(const IO::Path&, IO::Path); | |
1159 | +//! \since build 899 | |
1160 | +//!@{ | |
1161 | +//! \note 参数指定程序映像的路径字符串。 | |
1162 | +YB_ATTR_nodiscard YF_API YB_PURE bool | |
1163 | +CheckLocalFHSLayout(const string&); | |
1164 | + | |
1165 | +/*! | |
1166 | +\brief 取指定程序映像的路径字符串对应的局部 fHS 根路径。 | |
1167 | +\sa CheckLocalFHSLayout | |
1168 | +\sa FetchRootpath_string | |
1169 | + | |
1170 | +若框架根路径的 CheckLocalFHSLayout 检查通过,局部 fHS 根路径为对应的 $PREFIX ; | |
1171 | +否则,局部 FHS 根路径路径为空。 | |
1172 | +*/ | |
1173 | +YB_ATTR_nodiscard YF_API YB_PURE IO::Path | |
1174 | +GetLocalFHSRootPathOf(const string&); | |
1175 | +//!@} | |
1176 | +//!@} | |
1177 | + | |
1178 | + | |
1179 | +/*! | |
1180 | +\brief 根路径块:保存参数作为根路径初始化的路径信息。 | |
1181 | +\warning 非虚析构。 | |
1182 | +\note 可保存和检查 FHS 路径。 | |
1183 | +*/ | |
1184 | +class YF_API RootPathBlock | |
1185 | +{ | |
1186 | +private: | |
1187 | + string saved; | |
1188 | + IO::Path current; | |
1189 | + IO::Path parent; | |
1190 | + | |
1191 | +public: | |
1192 | + RootPathBlock(const string& path) | |
1193 | + : RootPathBlock(string(path, path.get_allocator())) | |
1194 | + {} | |
1195 | + RootPathBlock(string&& path) | |
1196 | + : saved(std::move(path)), current(saved), parent(current / u"..") | |
1197 | + {} | |
1198 | + DefDeCopyMoveCtorAssignment(RootPathBlock) | |
1199 | + | |
1200 | + DefGetter(const ynothrow, const IO::Path&, Parent, parent) | |
1201 | + /*! | |
1202 | + \brief 取保存的根路径字符串。 | |
1203 | + \return 初始化根路径块的路径字符串。 | |
1204 | + */ | |
1205 | + DefGetter(const ynothrow, const string&, PathString, saved) | |
1206 | + /*! | |
1207 | + \brief 取保存的局部 FHS 根路径。 | |
1208 | + \return 等价 Deployment::GetLocalFHSRootPathOf 应用到保存的根目录路径的值。 | |
1209 | + \sa Deployment::GetLocalFHSRootPathOf | |
1210 | + \sa GetPathString | |
1211 | + */ | |
1212 | + YB_ATTR_nodiscard YB_PURE const IO::Path& | |
1213 | + GetSavedLocalFHSRootPath() const; | |
1214 | + | |
1215 | + /*! | |
1216 | + \brief 判断是否满足局部 FHS 路径。 | |
1217 | + \sa CheckLocalFHSLayout | |
1218 | + */ | |
1219 | + YB_ATTR_nodiscard YB_PURE bool | |
1220 | + HasLocalFHSLayout() const; | |
1221 | + | |
1222 | + /*! | |
1223 | + \brief 取确保以分隔符结尾的当前工作目录路径。 | |
1224 | + \note 可作为平台中立的布局根路径实现。 | |
1225 | + */ | |
1226 | + YB_ATTR_nodiscard YB_PURE static string | |
1227 | + FetchCurrentWorkingDirectoryPath(string::allocator_type = {}); | |
1228 | +}; | |
1229 | +//!@} | |
1230 | + | |
1231 | + | |
1119 | 1232 | /*! |
1120 | 1233 | \note 第一参数和第二参数分别为目标和源路径。 |
1121 | 1234 | \see 工具脚本 \c SHBuild-common.sh 。 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2014-2016, 2022 FrankHB. | |
2 | + © 2014-2016, 2022-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file ImageProcessing.h |
12 | 12 | \ingroup Service |
13 | 13 | \brief 图像处理。 |
14 | -\version r284 | |
14 | +\version r305 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 554 |
17 | 17 | \par 创建时间: |
18 | 18 | 2014-11-16 16:33:35 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-11-28 20:07 +0800 | |
20 | + 2023-12-20 20:23 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -44,7 +44,7 @@ | ||
44 | 44 | { |
45 | 45 | |
46 | 46 | //! \since build 555 |
47 | -//@{ | |
47 | +//!@{ | |
48 | 48 | //! \brief 图像缩放类型。 |
49 | 49 | using ImageScale = ystdex::fixed_point<yimpl(std::uint32_t, 12U)>; |
50 | 50 |
@@ -54,7 +54,7 @@ | ||
54 | 54 | */ |
55 | 55 | YF_API CompactPixmap |
56 | 56 | Zoom(const HBitmap&, ImageScale); |
57 | -//@} | |
57 | +//!@} | |
58 | 58 | |
59 | 59 | |
60 | 60 | /*! |
@@ -94,7 +94,8 @@ | ||
94 | 94 | //! \since build 555 |
95 | 95 | DefDeMoveAssignment(ZoomedImageCache) |
96 | 96 | |
97 | - DefGetter(const ynothrow, const Container&, Bitmaps, bitmaps) | |
97 | + YB_ATTR_nodiscard | |
98 | + DefGetter(const ynothrow, const Container&, Bitmaps, bitmaps) | |
98 | 99 | |
99 | 100 | //! \since build 555 |
100 | 101 | shared_ptr<Image> |
@@ -141,7 +142,7 @@ | ||
141 | 142 | \pre 断言:区域下限分量不大于区域上限分量。 |
142 | 143 | \note 若起始缩放比例小于下限则由图像大小计算。 |
143 | 144 | */ |
144 | - //@{ | |
145 | + //!@{ | |
145 | 146 | //! \brief 构造:使用指定路径、显示区域下限、显示区域上限和起始缩放比例。 |
146 | 147 | template<typename _type, |
147 | 148 | yimpl(typename = ystdex::exclude_self_t<ImagePages, _type>)> |
@@ -151,23 +152,26 @@ | ||
151 | 152 | {} |
152 | 153 | //! \brief 构造:使用指定缓存、显示区域下限、显示区域上限和起始缩放比例。 |
153 | 154 | ImagePages(ZoomedImageCache&&, const Size&, const Size&, ImageScale); |
154 | - //@} | |
155 | + //!@} | |
155 | 156 | DefDeMoveCtor(ImagePages) |
156 | 157 | |
157 | 158 | DefDeMoveAssignment(ImagePages) |
158 | 159 | |
159 | 160 | //! \since build 558 |
160 | - DefGetterMem(const ynothrow, const vector<HBitmap>&, Bitmaps, cache) | |
161 | + YB_ATTR_nodiscard | |
162 | + DefGetterMem(const ynothrow, const vector<HBitmap>&, Bitmaps, cache) | |
161 | 163 | //! \since build 557 |
162 | - //@{ | |
163 | - DefGetter(const ynothrow, size_t, Count, cache.GetBitmaps().size()) | |
164 | - DefGetter(const ynothrow, size_t, Index, index) | |
165 | - //@} | |
164 | + //!@{ | |
165 | + YB_ATTR_nodiscard | |
166 | + DefGetter(const ynothrow, size_t, Count, cache.GetBitmaps().size()) | |
167 | + YB_ATTR_nodiscard DefGetter(const ynothrow, size_t, Index, index) | |
168 | + //!@} | |
166 | 169 | //! \since build 576 |
167 | - DefGetter(const ynothrow, ImageScale, Scale, scale) | |
168 | - DefGetter(const ynothrow, const Size&, ViewSize, view_size) | |
170 | + YB_ATTR_nodiscard DefGetter(const ynothrow, ImageScale, Scale, scale) | |
171 | + YB_ATTR_nodiscard | |
172 | + DefGetter(const ynothrow, const Size&, ViewSize, view_size) | |
169 | 173 | |
170 | - //! \pre 断言: <tt>Brush.ImagePtr</tt> 。 | |
174 | + //! \pre 断言:\c Brush.ImagePtr 。 | |
171 | 175 | void |
172 | 176 | AdjustOffset(const Size&); |
173 | 177 |
@@ -178,7 +182,7 @@ | ||
178 | 182 | |
179 | 183 | public: |
180 | 184 | /*! |
181 | - \pre 断言: <tt>Brush.ImagePtr</tt> 。 | |
185 | + \pre 断言:\c Brush.ImagePtr 。 | |
182 | 186 | \since build 554 |
183 | 187 | */ |
184 | 188 | void |
@@ -199,7 +203,7 @@ | ||
199 | 203 | \return 是否成功进行了缩放。 |
200 | 204 | \note 偏移量相对画刷左上角。 |
201 | 205 | */ |
202 | - //@{ | |
206 | + //!@{ | |
203 | 207 | /*! |
204 | 208 | \brief 按指定的比例变化量和偏移量缩放。 |
205 | 209 | \exception std::invalid_argument 异常中立:由 ZoomTo 抛出。 |
@@ -226,7 +230,7 @@ | ||
226 | 230 | */ |
227 | 231 | bool |
228 | 232 | ZoomTo(float, const Point&); |
229 | - //@} | |
233 | + //!@} | |
230 | 234 | }; |
231 | 235 | |
232 | 236 | } // namespace Drawing; |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2009-2017, 2019, 2021-2022 FrankHB. | |
2 | + © 2009-2017, 2019, 2021-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file YGDI.h |
12 | 12 | \ingroup Service |
13 | 13 | \brief 平台无关的图形设备接口。 |
14 | -\version r4055 | |
14 | +\version r4079 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 566 |
17 | 17 | \par 创建时间: |
18 | 18 | 2009-12-14 18:29:46 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-02-28 05:48 +0800 | |
20 | + 2023-12-20 20:26 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -99,9 +99,9 @@ | ||
99 | 99 | }; |
100 | 100 | |
101 | 101 | //! \since build 850 |
102 | -//@{ | |
102 | +//!@{ | |
103 | 103 | //! \relates Padding |
104 | -//@{ | |
104 | +//!@{ | |
105 | 105 | //! \brief 加法逆元:对应分量调用一元 operator- 。 |
106 | 106 | YB_ATTR_nodiscard YB_PURE yconstfn |
107 | 107 | PDefHOp(Padding, -, const Padding& x) ynothrow |
@@ -126,7 +126,7 @@ | ||
126 | 126 | SPos(x.Top * ptrdiff_t(n)), SPos(x.Bottom * ptrdiff_t(n)))) |
127 | 127 | |
128 | 128 | //! \note 若边距过大,则矩形的宽或高可能为 0 。 |
129 | -//@{ | |
129 | +//!@{ | |
130 | 130 | //! \brief 加法:缩小屏幕标准矩形,相对位置由指定边距决定。 |
131 | 131 | YB_ATTR_nodiscard YF_API YB_PURE Rect |
132 | 132 | operator+(const Rect&, const Padding&) ynothrow; |
@@ -135,12 +135,12 @@ | ||
135 | 135 | YB_ATTR_nodiscard YB_PURE inline |
136 | 136 | PDefHOp(Rect, -, const Rect& r, const Padding& m) ynothrow |
137 | 137 | ImplRet(r + -m) |
138 | -//@} | |
139 | -//@} | |
138 | +//!@} | |
139 | +//!@} | |
140 | 140 | |
141 | 141 | |
142 | 142 | //! \warning 不检查溢出。 |
143 | -//@{ | |
143 | +//!@{ | |
144 | 144 | //! \brief 取水平边距和。 |
145 | 145 | YB_ATTR_nodiscard YB_PURE yconstfn |
146 | 146 | PDefH(SDst, GetHorizontalOf, const Padding& m) ynothrowv |
@@ -150,7 +150,7 @@ | ||
150 | 150 | YB_ATTR_nodiscard YB_PURE yconstfn |
151 | 151 | PDefH(SDst, GetVerticalOf, const Padding& m) ynothrowv |
152 | 152 | ImplRet(SDst(ystdex::max<SPos>(0, m.Top) + ystdex::max<SPos>(0, m.Bottom))) |
153 | -//@} | |
153 | +//!@} | |
154 | 154 | |
155 | 155 | |
156 | 156 | //! \brief 取内边界相对外边界的边距。 |
@@ -182,7 +182,7 @@ | ||
182 | 182 | */ |
183 | 183 | YB_ATTR_nodiscard YF_API Point |
184 | 184 | ClipMargin(PaintContext&, const Padding&, const Size&) ynothrow; |
185 | -//@} | |
185 | +//!@} | |
186 | 186 | |
187 | 187 | |
188 | 188 | /*! |
@@ -213,7 +213,8 @@ | ||
213 | 213 | using Graphics::GetWidth; |
214 | 214 | using Graphics::GetSize; |
215 | 215 | //! \since build 566 |
216 | - DefGetter(const ynothrow ImplI(IImage), Graphics, Context, *this) | |
216 | + YB_ATTR_nodiscard | |
217 | + DefGetter(const ynothrow ImplI(IImage), Graphics, Context, *this) | |
217 | 218 | |
218 | 219 | //! \since build 409 |
219 | 220 | DefClone(const ImplI(IImage), BasicImage) |
@@ -233,13 +234,13 @@ | ||
233 | 234 | { |
234 | 235 | private: |
235 | 236 | //! \since build 566 |
236 | - //@{ | |
237 | + //!@{ | |
237 | 238 | using BaseType = GGraphics<unique_ptr<Pixel[]>>; |
238 | 239 | |
239 | 240 | protected: |
240 | 241 | using BaseType::pBuffer; |
241 | 242 | using BaseType::sGraphics; |
242 | - //@} | |
243 | + //!@} | |
243 | 244 | |
244 | 245 | public: |
245 | 246 | /*! |
@@ -260,27 +261,27 @@ | ||
260 | 261 | DefDeMoveCtor(CompactPixmap) |
261 | 262 | |
262 | 263 | //! \since build 768 |
263 | - //@{ | |
264 | + //!@{ | |
264 | 265 | //! \brief 复制赋值:使用复制和交换。 |
265 | 266 | PDefHOp(CompactPixmap&, =, const CompactPixmap& buf) |
266 | 267 | ImplRet(ystdex::copy_and_swap(*this, buf)) |
267 | 268 | DefDeMoveAssignment(CompactPixmap) |
268 | - //@} | |
269 | + //!@} | |
269 | 270 | |
270 | 271 | //! \since build 566 |
271 | - //@{ | |
272 | + //!@{ | |
272 | 273 | using BaseType::operator!; |
273 | 274 | |
274 | 275 | using BaseType::operator bool; |
275 | 276 | |
276 | - DefGetter(const ynothrow, BitmapPtr, BufferPtr, | |
277 | + YB_ATTR_nodiscard DefGetter(const ynothrow, BitmapPtr, BufferPtr, | |
277 | 278 | BaseType::GetBufferPtr().get()) |
278 | 279 | using BaseType::GetHeight; |
279 | 280 | using BaseType::GetWidth; |
280 | 281 | using BaseType::GetSize; |
281 | - DefGetter(const ynothrow ImplI(IImage), Graphics, Context, | |
282 | + YB_ATTR_nodiscard DefGetter(const ynothrow ImplI(IImage), Graphics, Context, | |
282 | 283 | Graphics(GetBufferPtr(), GetSize())) |
283 | - //@} | |
284 | + //!@} | |
284 | 285 | |
285 | 286 | /*! |
286 | 287 | \brief 设置内容。 |
@@ -353,23 +354,24 @@ | ||
353 | 354 | DefDeMoveCtor(CompactPixmapEx) |
354 | 355 | |
355 | 356 | //! \since build 768 |
356 | - //@{ | |
357 | + //!@{ | |
357 | 358 | //! \brief 复制赋值:使用复制和交换。 |
358 | 359 | PDefHOp(CompactPixmapEx&, =, const CompactPixmapEx& buf) |
359 | 360 | ImplRet(ystdex::copy_and_swap(*this, buf)) |
360 | 361 | DefDeMoveAssignment(CompactPixmapEx) |
361 | - //@} | |
362 | + //!@} | |
362 | 363 | |
363 | 364 | /*! |
364 | 365 | \brief 取 Alpha 缓冲区的指针。 |
365 | 366 | \since build 417 |
366 | 367 | */ |
367 | - DefGetter(const ynothrow, AlphaType*, BufferAlphaPtr, pBufferAlpha.get()) | |
368 | + YB_ATTR_nodiscard DefGetter(const ynothrow, AlphaType*, BufferAlphaPtr, | |
369 | + pBufferAlpha.get()) | |
368 | 370 | /*! |
369 | 371 | \brief 取 Alpha 缓冲区占用空间。 |
370 | 372 | \since build 407 |
371 | 373 | */ |
372 | - DefGetter(const ynothrow, size_t, SizeOfBufferAlpha, | |
374 | + YB_ATTR_nodiscard DefGetter(const ynothrow, size_t, SizeOfBufferAlpha, | |
373 | 375 | sizeof(AlphaType) * size_t(GetAreaOf(GetSize()))) |
374 | 376 | |
375 | 377 | using CompactPixmap::SetSize; |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2013-2016, 2019-2020, 2022 FrankHB. | |
2 | + © 2013-2016, 2019-2020, 2022-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file Loader.h |
12 | 12 | \ingroup UI |
13 | 13 | \brief 动态 GUI 加载。 |
14 | -\version r684 | |
14 | +\version r696 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 433 |
17 | 17 | \par 创建时间: |
18 | 18 | 2013-08-01 20:37:16 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-09-22 23:33 +0800 | |
20 | + 2023-12-23 16:44 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -29,7 +29,7 @@ | ||
29 | 29 | #define YSL_INC_UI_Loader_h_ 1 |
30 | 30 | |
31 | 31 | #include "YModules.h" |
32 | -#include YFM_YSLib_UI_YUIContainer | |
32 | +#include YFM_YSLib_UI_YUIContainer // for YSLib::make_unique; | |
33 | 33 | #include YFM_YSLib_Core_ValueNode |
34 | 34 | #include <ystdex/cast.hpp> // for ystdex::polymorphic_downcast; |
35 | 35 | #include <ystdex/function.hpp> // for ystdex::unchecked_function; |
@@ -54,7 +54,7 @@ | ||
54 | 54 | static unique_ptr<IWidget> |
55 | 55 | CreateUniqueWidget(_tParams&&... args) |
56 | 56 | { |
57 | - return make_unique<_tWidget>(yforward(args)...); | |
57 | + return YSLib::make_unique<_tWidget>(yforward(args)...); | |
58 | 58 | } |
59 | 59 | |
60 | 60 | /*! |
@@ -118,12 +118,12 @@ | ||
118 | 118 | |
119 | 119 | /* |
120 | 120 | \throw WidgetNotFound 没有找到指定名称的部件。 |
121 | -\note 不抛出 std::out_of_range (已全部捕获并抛出为 WidgetNotFound )。 | |
121 | +\note 不抛出 \c std::out_of_range(已全部捕获并抛出为 WidgetNotFound )。 | |
122 | 122 | \since build 667 |
123 | 123 | */ |
124 | -//@{ | |
124 | +//!@{ | |
125 | 125 | //! \brief 按指定名称访问子部件节点。 |
126 | -//@{ | |
126 | +//!@{ | |
127 | 127 | yconstfn PDefH(ValueNode&, AccessWidgetNode, ValueNode& nd) |
128 | 128 | ImplRet(nd) |
129 | 129 | template<typename... _tParams> |
@@ -135,13 +135,13 @@ | ||
135 | 135 | CatchThrow(std::out_of_range&, |
136 | 136 | WidgetNotFound(node.GetName(), "Widget children not found.")) |
137 | 137 | } |
138 | -//@} | |
138 | +//!@} | |
139 | 139 | |
140 | 140 | /*! |
141 | 141 | \brief 按指定名称访问子部件。 |
142 | 142 | \exception bad_any_cast 异常中立:由 Access 抛出。 |
143 | 143 | */ |
144 | -//@{ | |
144 | +//!@{ | |
145 | 145 | YF_API IWidget& |
146 | 146 | AccessWidget(const ValueNode&); |
147 | 147 | template<typename... _tParams> |
@@ -157,8 +157,8 @@ | ||
157 | 157 | { |
158 | 158 | return dynamic_cast<_tWidget&>(AccessWidget(node, yforward(args)...)); |
159 | 159 | } |
160 | -//@} | |
161 | -//@} | |
160 | +//!@} | |
161 | +//!@} | |
162 | 162 | |
163 | 163 | |
164 | 164 | //! \since build 494 |
@@ -252,7 +252,7 @@ | ||
252 | 252 | {} |
253 | 253 | |
254 | 254 | //! \since build 888 |
255 | - //@{ | |
255 | + //!@{ | |
256 | 256 | //! \exception std::out_of_range 异常中立:找不到内部类型节点。 |
257 | 257 | unique_ptr<IWidget> |
258 | 258 | DetectWidgetNode(const ValueNode&) const; |
@@ -278,7 +278,7 @@ | ||
278 | 278 | */ |
279 | 279 | ValueNode |
280 | 280 | TransformUILayout(const ValueNode&) const; |
281 | - //@} | |
281 | + //!@} | |
282 | 282 | }; |
283 | 283 | |
284 | 284 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2010-2016, 2019-2020, 2022 FrankHB. | |
2 | + © 2010-2016, 2019-2020, 2022-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file YControl.h |
12 | 12 | \ingroup UI |
13 | 13 | \brief 样式无关的控件。 |
14 | -\version r4880 | |
14 | +\version r4887 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 572 |
17 | 17 | \par 创建时间: |
18 | 18 | 2010-02-18 13:44:24 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-11-28 20:01 +0800 | |
20 | + 2023-12-20 20:32 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -78,7 +78,7 @@ | ||
78 | 78 | {} |
79 | 79 | |
80 | 80 | //! \since build 581 |
81 | - //@{ | |
81 | + //!@{ | |
82 | 82 | PDefH(bool, IsEventEnabled, VisualEvent id) const ImplI(AController) |
83 | 83 | ImplRet(AController::IsEnabled() && !event_mask[id]) |
84 | 84 |
@@ -88,9 +88,10 @@ | ||
88 | 88 | //! \since build 850 |
89 | 89 | YB_ATTR_nodiscard YB_PURE EventRef |
90 | 90 | GetEventRef(VisualEvent, EventItem(&)()) const override; |
91 | - //@} | |
91 | + //!@} | |
92 | 92 | //! \brief 取事件映射表。 |
93 | - DefGetter(const ynothrow, VisualEventMap&, EventMap, EventMap) | |
93 | + YB_ATTR_nodiscard | |
94 | + DefGetter(const ynothrow, VisualEventMap&, EventMap, EventMap) | |
94 | 95 | |
95 | 96 | //! \since build 581 |
96 | 97 | PDefH(void, SetEventEnabled, VisualEvent id, bool b) ImplI(AController) |
@@ -290,8 +291,8 @@ | ||
290 | 291 | /*! |
291 | 292 | \brief 构造:使用指定边界,无背景。 |
292 | 293 | \note 使用扩展控件事件表加载的事件处理器。 |
293 | - \note 加载事件处理器: Move 、 Resize 、 GotFocus 和 LostFocus 时自动无效化。 | |
294 | - \note 加载事件处理器: OnTouchDown_RequestToFrontFocused 。 | |
294 | + \note 加载事件处理器:Move 、 Resize 、 GotFocus 和 LostFocus 时自动无效化。 | |
295 | + \note 加载事件处理器:OnTouchDown_RequestToFrontFocused 。 | |
295 | 296 | \sa Widget::Widget |
296 | 297 | \since build 485 |
297 | 298 | */ |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2011-2016, 2019-2020, 2022 FrankHB. | |
2 | + © 2011-2016, 2019-2020, 2022-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file YUIContainer.h |
12 | 12 | \ingroup UI |
13 | 13 | \brief 样式无关的 GUI 容器。 |
14 | -\version r2159 | |
14 | +\version r2172 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 563 |
17 | 17 | \par 创建时间: |
18 | 18 | 2011-01-22 07:59:47 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-11-28 20:00 +0800 | |
20 | + 2023-12-20 20:35 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -174,14 +174,14 @@ | ||
174 | 174 | |
175 | 175 | |
176 | 176 | //! \since build 555 |
177 | -//@{ | |
177 | +//!@{ | |
178 | 178 | //! \brief Z 顺序类型:覆盖顺序,值越大表示越接近顶层。 |
179 | 179 | using ZOrder = std::uint8_t; |
180 | 180 | //! \brief 默认 Z 顺序值。 |
181 | 181 | const ZOrder DefaultZOrder(64); |
182 | 182 | //! \brief 默认窗口 Z 顺序值。 |
183 | 183 | const ZOrder DefaultWindowZOrder(128); |
184 | -//@} | |
184 | +//!@} | |
185 | 185 | |
186 | 186 | |
187 | 187 | /*! |
@@ -219,7 +219,7 @@ | ||
219 | 219 | |
220 | 220 | public: |
221 | 221 | //! \since build 537 |
222 | - //@{ | |
222 | + //!@{ | |
223 | 223 | //! \brief 无参数构造:默认实现。 |
224 | 224 | DefDeCtor(MLinearUIContainer) |
225 | 225 | DefDeMoveCtor(MLinearUIContainer) |
@@ -239,20 +239,20 @@ | ||
239 | 239 | */ |
240 | 240 | bool |
241 | 241 | operator-=(IWidget&); |
242 | - //@} | |
242 | + //!@} | |
243 | 243 | |
244 | 244 | /*! |
245 | 245 | \brief 取指定索引的部件引用。 |
246 | 246 | \pre 断言:参数小于部件数。 |
247 | 247 | */ |
248 | - //@{ | |
248 | + //!@{ | |
249 | 249 | PDefHOp(IWidget&, [], size_t idx) ynothrowv |
250 | 250 | ImplRet(YAssert(idx < GetCount(), "Index is out of range."), |
251 | 251 | vWidgets[idx]) |
252 | 252 | PDefHOp(IWidget&, [], size_t idx) const ynothrowv |
253 | 253 | ImplRet(YAssert(idx < GetCount(), "Index is out of range."), |
254 | 254 | vWidgets[idx]) |
255 | - //@} | |
255 | + //!@} | |
256 | 256 | |
257 | 257 | /*! |
258 | 258 | \brief 判断是否包含指定部件。 |
@@ -265,7 +265,7 @@ | ||
265 | 265 | \brief 取部件数。 |
266 | 266 | \since build 495 |
267 | 267 | */ |
268 | - DefGetter(const ynothrow, size_t, Count, vWidgets.size()) | |
268 | + YB_ATTR_nodiscard DefGetter(const ynothrow, size_t, Count, vWidgets.size()) | |
269 | 269 | |
270 | 270 | /*! |
271 | 271 | \brief 查找部件。 |
@@ -287,12 +287,12 @@ | ||
287 | 287 | \exception std::out_of_range 异常中立:由 vWidgets.at 抛出。 |
288 | 288 | \since build 563 |
289 | 289 | */ |
290 | - //@{ | |
290 | + //!@{ | |
291 | 291 | PDefH(IWidget&, at, size_t idx) |
292 | 292 | ImplRet(vWidgets.at(idx)) |
293 | 293 | PDefH(IWidget&, at, size_t idx) const |
294 | 294 | ImplRet(vWidgets.at(idx)) |
295 | - //@} | |
295 | + //!@} | |
296 | 296 | |
297 | 297 | iterator |
298 | 298 | begin(); |
@@ -337,7 +337,7 @@ | ||
337 | 337 | |
338 | 338 | public: |
339 | 339 | //! \since build 537 |
340 | - //@{ | |
340 | + //!@{ | |
341 | 341 | /*! |
342 | 342 | \brief 无参数构造:默认实现。 |
343 | 343 | */ |
@@ -361,7 +361,7 @@ | ||
361 | 361 | */ |
362 | 362 | bool |
363 | 363 | operator-=(IWidget&); |
364 | - //@} | |
364 | + //!@} | |
365 | 365 | |
366 | 366 | /*! |
367 | 367 | \brief 判断是否包含指定部件。 |
@@ -373,7 +373,7 @@ | ||
373 | 373 | \brief 取部件数。 |
374 | 374 | \since build 495 |
375 | 375 | */ |
376 | - DefGetter(const ynothrow, size_t, Count, mWidgets.size()) | |
376 | + YB_ATTR_nodiscard DefGetter(const ynothrow, size_t, Count, mWidgets.size()) | |
377 | 377 | |
378 | 378 | /*! |
379 | 379 | \brief 向部件组添加部件。 |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file Initialization.cpp |
12 | 12 | \ingroup Helper |
13 | 13 | \brief 框架初始化。 |
14 | -\version r4118 | |
14 | +\version r4326 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since 早于 build 132 |
17 | 17 | \par 创建时间: |
18 | 18 | 2009-10-21 23:15:08 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2023-10-02 16:47 +0800 | |
20 | + 2024-02-25 03:57 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -26,16 +26,13 @@ | ||
26 | 26 | |
27 | 27 | |
28 | 28 | #include "Helper/YModules.h" |
29 | -#include YFM_Helper_Initialization // for IO::FetchSeparator, | |
30 | -// FetchCurrentWorkingDirectory, IO::MaxPathLength, GeneralEvent, | |
31 | -// pmr::new_delete_resource_t, ystdex::nptr, UniqueLockedOutputFileStream, | |
32 | -// std::ios_base, air, value_map, mutex, lock_guard, IO::EnsureDirectory, | |
33 | -// IO::VerifyDirectories, PerformKeyAction, IO::TraverseChildren, NodeCategory, | |
34 | -// NativePathView, IsDirectory, FontPath, String; | |
35 | -#if !(YCL_Win32 || YCL_Linux) | |
36 | -# include <ystdex/string.hpp> // for ystdex::rtrim; | |
37 | -# include YFM_YCLib_FileSystem // for platform::EndsWithNonSeperator; | |
38 | -#endif | |
29 | +#include YFM_Helper_Initialization // for IO::Path, Deployment::RootPathBlock, | |
30 | +// IO::FetchSeparator, GeneralEvent, pmr::new_delete_resource_t, ystdex::nptr, | |
31 | +// byte, size_t, SharedInputMappedFileStream, UniqueLockedOutputFileStream, | |
32 | +// IO::LoadMappedModule, std::ios_base, air, value_map, mutex, lock_guard, | |
33 | +// IO::EnsureDirectory, IO::VerifyDirectories, PerformKeyAction, | |
34 | +// IO::TraverseChildren, NodeCategory, NativePathView, IsDirectory, FontPath, | |
35 | +// String; | |
39 | 36 | #if YCL_Win32 |
40 | 37 | # include YFM_Win32_YCLib_NLS // for platform_ex::FetchModuleFileName, |
41 | 38 | // platform_ex::FetchDBCSOffset, platform_ex::WCSToUTF8, |
@@ -44,14 +41,13 @@ | ||
44 | 41 | #include YFM_CHRLib_MappingEx // for CHRLib::cp113_lkp; |
45 | 42 | #include YFM_NPL_Configuration // for NPL::Configuration, A1::NodeLoader; |
46 | 43 | #include YFM_YSLib_Service_TextFile // for Text::BOM_UTF_8, Text::CheckBOM; |
47 | -#include <ystdex/string.hpp> // for ystdex::write_literal, ystdex::sfmt; | |
44 | +#include <ystdex/string.hpp> // for ystdex::sfmt; | |
48 | 45 | #include <cerrno> // for errno; |
49 | 46 | #include <ystdex/scope_guard.hpp> // for ystdex::swap_guard; |
50 | 47 | #include YFM_YSLib_Adaptor_YAdaptor // for FetchEnvironmentVariable; |
51 | 48 | #include YFM_Helper_GUIApplication // for FetchAppInstance, |
52 | 49 | // Application::AddExit, FetchEnvironment; |
53 | 50 | #include YFM_YSLib_Core_YException // for ExtractAndTrace; |
54 | -#include YFM_YSLib_Core_YStorage // for FetchStaticRef; | |
55 | 51 | #include YFM_Helper_Environment // for complete type Environment introduced by |
56 | 52 | // FetchEnvironment; |
57 | 53 |
@@ -108,16 +104,14 @@ | ||
108 | 104 | # define YF_Helper_Initialization_UseFallbackConf_ true |
109 | 105 | #endif |
110 | 106 | |
111 | -struct RootPathCache | |
107 | +//! \note 初始化时使用平台路径分隔符结尾的目录路径字符串。 | |
108 | +struct RootPathCache final : public Deployment::RootPathBlock | |
112 | 109 | { |
113 | - string PathString; | |
114 | - IO::Path Path; | |
115 | - IO::Path Parent; | |
116 | - | |
117 | - // XXX: Similar to %FetchConfPaths as of the concurrent execution. | |
110 | + // XXX: Similar to the static object initialization in %LoadNPLA1FileVec as | |
111 | + // of the concurrent execution. | |
118 | 112 | //! \since build 957 |
119 | 113 | RootPathCache(string::allocator_type a) |
120 | - : PathString([&]{ | |
114 | + : RootPathBlock([&]{ | |
121 | 115 | #if YCL_Win32 |
122 | 116 | IO::Path image(platform::ucast( |
123 | 117 | platform_ex::FetchModuleFileName({}, a).data()), a); |
@@ -128,7 +122,7 @@ | ||
128 | 122 | |
129 | 123 | const auto& dir(image.Verify()); |
130 | 124 | |
131 | - if(!dir.empty() && dir.back() == FetchSeparator<char16_t>()) | |
125 | + if(!dir.empty() && dir.back() == IO::FetchSeparator<char16_t>()) | |
132 | 126 | return dir.GetMBCS(); |
133 | 127 | } |
134 | 128 | #elif YCL_Android |
@@ -167,22 +161,14 @@ | ||
167 | 161 | return dir; |
168 | 162 | } |
169 | 163 | #else |
170 | - // XXX: Trimming is necessary, because it is unspecified to have | |
171 | - // trailing slashes with %platform::ugetcwd as POSIX.1 2004. | |
172 | - auto root_path(ystdex::rtrim(FetchCurrentWorkingDirectory<char>( | |
173 | - IO::MaxPathLength, a), IO::FetchSeparator<char>())); | |
174 | - | |
175 | - YAssert(platform::EndsWithNonSeperator(root_path), | |
176 | - "Invalid argument found."); | |
177 | - root_path += IO::FetchSeparator<char>(); | |
178 | - return root_path; | |
164 | + return FetchCurrentWorkingDirectoryPath(a); | |
179 | 165 | // TODO: Add similar implemnetation for BSD family OS, etc. |
180 | 166 | #endif |
181 | 167 | throw GeneralEvent("Failed finding working root path."); |
182 | - }()), Path(PathString), Parent(Path / u"..") | |
168 | + }()) | |
183 | 169 | { |
184 | 170 | YTraceDe(Informative, "Initialized root directory path '%s'.", |
185 | - PathString.c_str()); | |
171 | + GetPathString().c_str()); | |
186 | 172 | } |
187 | 173 | }; |
188 | 174 |
@@ -203,6 +189,10 @@ | ||
203 | 189 | return cache; |
204 | 190 | } |
205 | 191 | |
192 | +//! \since build 982 | |
193 | +YB_ATTR_nodiscard YB_PURE inline PDefH(const string&, FetchRootPathString, ) | |
194 | + ImplRet(FetchRootPathCache().GetPathString()) | |
195 | + | |
206 | 196 | #if YF_Helper_Initialization_UseFallbackConf_ |
207 | 197 | // XXX: Currently all platforms using fallback configurations have the same |
208 | 198 | // image path and root path. |
@@ -213,30 +203,6 @@ | ||
213 | 203 | } |
214 | 204 | #endif |
215 | 205 | |
216 | -YB_ATTR_nodiscard YB_PURE bool | |
217 | -CheckLocalFHSLayoutImpl(const IO::Path& prefix, IO::Path bin) | |
218 | -{ | |
219 | - if(bin != prefix) | |
220 | - { | |
221 | - const IO::Path | |
222 | - paths[]{prefix, std::move(bin), prefix / u"lib", prefix / u"share"}; | |
223 | - | |
224 | - return IO::VerifyDirectories(paths); | |
225 | - } | |
226 | - return {}; | |
227 | -} | |
228 | - | |
229 | -YB_ATTR_nodiscard YB_PURE bool | |
230 | -CheckLocalFHSLayoutWithCache(const RootPathCache& cache) | |
231 | -{ | |
232 | -# if true | |
233 | - // XXX: This is more efficient. | |
234 | - return CheckLocalFHSLayoutImpl(cache.Parent, cache.Path); | |
235 | -# else | |
236 | - return CheckLocalFHSLayout(cache.PathString); | |
237 | -# endif | |
238 | -} | |
239 | - | |
240 | 206 | YB_ATTR_nodiscard YB_PURE const string& |
241 | 207 | FetchPreferredConfPath() |
242 | 208 | { |
@@ -244,12 +210,13 @@ | ||
244 | 210 | static string conf_path([]() -> string{ |
245 | 211 | auto& cache(FetchImagePathCache()); |
246 | 212 | |
247 | - if(CheckLocalFHSLayoutWithCache(cache)) | |
213 | + if(cache.HasLocalFHSLayout()) | |
248 | 214 | { |
249 | 215 | YTraceDe(Informative, "FHS layout is detected, using" |
250 | 216 | " '../var/YSLib/' relative to the program image path as the" |
251 | 217 | " preferred configuration path."); |
252 | - return (cache.Parent / u"var" / u"YSLib").GetString().GetMBCS(); | |
218 | + return | |
219 | + (cache.GetParent() / u"var" / u"YSLib").GetString().GetMBCS(); | |
253 | 220 | } |
254 | 221 | YTraceDe(Informative, "FHS layout is not detected, using the root path" |
255 | 222 | " as the preferred configuration path."); |
@@ -305,16 +272,6 @@ | ||
305 | 272 | #endif |
306 | 273 | |
307 | 274 | #if !CHRLib_NoDynamic_Mapping |
308 | -//! \since build 861 | |
309 | -MappedFile | |
310 | -LoadMappedModule(const std::string& path) | |
311 | -{ | |
312 | - TryRet(MappedFile(path)) | |
313 | - CatchExpr(..., std::throw_with_nested( | |
314 | - GeneralEvent("Loading module '" + path + "' failed."))) | |
315 | - YAssert(false, "Unreachable control found."); | |
316 | -} | |
317 | - | |
318 | 275 | # if YCL_Win32 |
319 | 276 | //! \since build 552 |
320 | 277 | const unsigned short* p_dbcs_off_936; |
@@ -338,7 +295,7 @@ | ||
338 | 295 | mapping_name.c_str()); |
339 | 296 | try |
340 | 297 | { |
341 | - mapped = LoadMappedModule(mapping_name); | |
298 | + mapped = IO::LoadMappedModule(mapping_name); | |
342 | 299 | if(mapped.GetSize() != 0) |
343 | 300 | CHRLib::cp113 = mapped.GetPtr(); |
344 | 301 | else |
@@ -391,13 +348,6 @@ | ||
391 | 348 | }; |
392 | 349 | #endif |
393 | 350 | |
394 | -//! \since build 721 | |
395 | -inline void | |
396 | -WriteNPLA1Stream(std::ostream& os, NPL::Configuration&& conf) | |
397 | -{ | |
398 | - ystdex::write_literal(os, Text::BOM_UTF_8) << std::move(conf); | |
399 | -} | |
400 | - | |
401 | 351 | //! \since build 971 |
402 | 352 | //!@{ |
403 | 353 | YB_ATTR_nodiscard ValueNode |
@@ -446,9 +396,9 @@ | ||
446 | 396 | ystdex::swap_guard<int, void, decltype(errno)&> gd(errno, 0); |
447 | 397 | |
448 | 398 | // XXX: Failed on race condition detected. |
449 | - if(UniqueLockedOutputFileStream uofs{path, std::ios_base::out | |
450 | - | std::ios_base::trunc | platform::ios_noreplace}) | |
451 | - WriteNPLA1Stream(uofs, Nonnull(creator)(a)); | |
399 | + if(UniqueLockedOutputFileStream uofs{path, | |
400 | + std::ios_base::out | std::ios_base::trunc | platform::ios_noreplace}) | |
401 | + WriteNPLA1StreamWithBOM(uofs, Nonnull(creator)(a)); | |
452 | 402 | else |
453 | 403 | { |
454 | 404 | int err(errno); |
@@ -462,10 +412,16 @@ | ||
462 | 412 | YTraceDe(Debug, "Created configuration."); |
463 | 413 | return LoadNPLA1FileDirect(disp, path, a, show_info); |
464 | 414 | } |
415 | +//!@} | |
465 | 416 | |
466 | -YB_ATTR_nodiscard YB_NONNULL(1) ValueNode | |
467 | -LoadNPLA1MemoryFallback(ValueNodeCreator creator, ValueNode::allocator_type a) | |
417 | +//! \since build 982 | |
418 | +YB_ATTR_nodiscard YB_NONNULL(2) ValueNode | |
419 | +LoadNPLA1MemoryFallback(ValueNode&& res, ValueNodeCreator creator, | |
420 | + ValueNode::allocator_type a) | |
468 | 421 | { |
422 | + if(res) | |
423 | + return std::move(res); | |
424 | + | |
469 | 425 | YTraceDe(Notice, "Trying fallback in memory..."); |
470 | 426 | |
471 | 427 | std::stringstream ss; |
@@ -473,7 +429,6 @@ | ||
473 | 429 | ss << Nonnull(creator)(a); |
474 | 430 | return TryReadRawNPLStream(ss, a); |
475 | 431 | } |
476 | -//!@} | |
477 | 432 | |
478 | 433 | //! \since build 899 |
479 | 434 | //!@{ |
@@ -488,9 +443,9 @@ | ||
488 | 443 | YB_ATTR_nodiscard YB_PURE VecRecordMap& |
489 | 444 | FetchNPLA1PathVecRecordRef() |
490 | 445 | { |
491 | - static VecRecordMap m(&FetchPMRResourceRef()); | |
446 | + static VecRecordMap vr(&FetchPMRResourceRef()); | |
492 | 447 | |
493 | - return m; | |
448 | + return vr; | |
494 | 449 | } |
495 | 450 | |
496 | 451 | inline YB_NONNULL(1) void |
@@ -499,13 +454,65 @@ | ||
499 | 454 | FetchNPLA1PathVecRecordRef().emplace(disp, conf_path); |
500 | 455 | } |
501 | 456 | |
502 | -//! \since build 971 | |
503 | -YB_ATTR_nodiscard YB_NONNULL(1, 3, 4) ValueNode | |
504 | -LoadNPLA1FileVec(const char* disp, const vector<string>& conf_paths, | |
505 | - const char* filename, ValueNodeCreator creator, ValueNode::allocator_type a, | |
506 | - bool show_info) | |
457 | +// XXX: Previously %LoadNPLA1MemoryFallback was used directly without the empty | |
458 | +// check and the conditional expressions in %LoadNPLA1FileVec and | |
459 | +// %LoadNPLA1File for the check were occasioanlly not the same: in | |
460 | +// %LoadNPLA1FileVec no %std::move was used on the 2nd operand. This is actualy | |
461 | +// a bit more efficient with x86_64 Linux G++ 13.1.1. However, consistency is | |
462 | +// more important, and it is even more efficient. | |
463 | +//! \since build 982 | |
464 | +YB_ATTR_nodiscard YB_NONNULL(1, 2, 3) ValueNode | |
465 | +LoadNPLA1FileVec(const char* disp, const char* filename, | |
466 | + ValueNodeCreator creator, ValueNode::allocator_type a, bool show_info) | |
507 | 467 | { |
508 | - auto res(TryInvoke([=]() -> ValueNode{ | |
468 | + static const struct Init final | |
469 | + { | |
470 | + vector<string> Paths; | |
471 | + | |
472 | + // XXX: This may be concurrently executed across multiple threads | |
473 | + // without %call_once. This is still assumed safe (free of race) | |
474 | + // because the result shall be the same in each thread, or when there | |
475 | + // are concurrent modifications on the environment variables, the | |
476 | + // synchronization should be done by the host environment. | |
477 | + Init() | |
478 | + : Paths([]() -> vector<string>{ | |
479 | + vector<string> res{FetchPreferredConfPath()}; | |
480 | + string var; | |
481 | + | |
482 | + if(FetchEnvironmentVariable(var, "HOME") && !var.empty()) | |
483 | + { | |
484 | + AddSuffix(var); | |
485 | + res.push_back(std::move(var)); | |
486 | + var.clear(); | |
487 | + } | |
488 | +#if YCL_Win32 | |
489 | + if(FetchEnvironmentVariable(var, "USERPROFILE") && !var.empty()) | |
490 | + { | |
491 | + AddSuffix(var); | |
492 | + res.push_back(std::move(var)); | |
493 | + var.clear(); | |
494 | + } | |
495 | +#endif | |
496 | + return res; | |
497 | + }()) | |
498 | + { | |
499 | + YTraceDe(Informative, | |
500 | + "Initialized enumerated configuration root paths."); | |
501 | + } | |
502 | + | |
503 | + private: | |
504 | + //! \since build 982 | |
505 | + static inline void | |
506 | + AddSuffix(string& var) | |
507 | + { | |
508 | + var += FetchSeparator<char>(); | |
509 | + var += ".YSLib"; | |
510 | + var += FetchSeparator<char>(); | |
511 | + } | |
512 | + } init; | |
513 | + const auto& conf_paths(init.Paths); | |
514 | + | |
515 | + return LoadNPLA1MemoryFallback(TryInvoke([=]() -> ValueNode{ | |
509 | 516 | for(const auto& conf_path : conf_paths) |
510 | 517 | { |
511 | 518 | const auto e(conf_path + filename); |
@@ -541,63 +548,11 @@ | ||
541 | 548 | } |
542 | 549 | } |
543 | 550 | return {}; |
544 | - })); | |
545 | - | |
546 | - return res ? res : LoadNPLA1MemoryFallback(creator, a); | |
547 | -} | |
548 | - | |
549 | -const vector<string>& | |
550 | -FetchConfPaths() | |
551 | -{ | |
552 | - static const struct Init final | |
553 | - { | |
554 | - vector<string> Paths; | |
555 | - | |
556 | - // XXX: This may be concurrently executed across multiple threads | |
557 | - // without %call_once. This is still assumed safe (free of race) | |
558 | - // because the result shall be the same in each thread, or when there | |
559 | - // are concurrent modifications on the environment variables, the | |
560 | - // synchronization should be done by the host environment. | |
561 | - Init() | |
562 | - : Paths([]() -> vector<string>{ | |
563 | - vector<string> res{FetchPreferredConfPath()}; | |
564 | - string var; | |
565 | - | |
566 | - if(FetchEnvironmentVariable(var, "HOME") && !var.empty()) | |
567 | - { | |
568 | - AddPostfix(var); | |
569 | - res.push_back(std::move(var)); | |
570 | - var.clear(); | |
571 | - } | |
572 | -#if YCL_Win32 | |
573 | - if(FetchEnvironmentVariable(var, "USERPROFILE") && !var.empty()) | |
574 | - { | |
575 | - AddPostfix(var); | |
576 | - res.push_back(std::move(var)); | |
577 | - var.clear(); | |
578 | - } | |
579 | -#endif | |
580 | - return res; | |
581 | - }()) | |
582 | - { | |
583 | - YTraceDe(Informative, | |
584 | - "Initialized enumerated configuration root paths."); | |
585 | - } | |
586 | - | |
587 | - private: | |
588 | - static inline void | |
589 | - AddPostfix(string& var) | |
590 | - { | |
591 | - var += FetchSeparator<char>(); | |
592 | - var += ".YSLib"; | |
593 | - var += FetchSeparator<char>(); | |
594 | - } | |
595 | - } init; | |
596 | - | |
597 | - return init.Paths; | |
551 | + }), creator, a); | |
598 | 552 | } |
599 | 553 | #endif |
600 | 554 | |
555 | +// XXX: Keeping this out-of-line can be a bit efficient. | |
601 | 556 | YB_ATTR_nodiscard YB_PURE const string& |
602 | 557 | FetchConfPathForSave() |
603 | 558 | { |
@@ -662,53 +617,12 @@ | ||
662 | 617 | } |
663 | 618 | |
664 | 619 | |
665 | -bool | |
666 | -CheckLocalFHSLayout(const string& path_string) | |
620 | +const Deployment::RootPathBlock& | |
621 | +FetchRootPathBlock() | |
667 | 622 | { |
668 | - IO::Path bin(path_string); | |
669 | - const auto prefix(bin / u".."); | |
670 | - | |
671 | - return CheckLocalFHSLayoutImpl(prefix, std::move(bin)); | |
672 | -} | |
673 | - | |
674 | -const IO::Path& | |
675 | -FetchLocalFHSRootPath() | |
676 | -{ | |
677 | -#if true | |
678 | - // XXX: This is more efficient. | |
679 | - auto& cache(FetchRootPathCache()); | |
680 | - | |
681 | - if(CheckLocalFHSLayoutWithCache(cache)) | |
682 | - return cache.Parent; | |
683 | - return FetchStaticRef<const IO::Path>(); | |
684 | -#else | |
685 | - static const auto path(GetLocalFHSRootPathOf(FetchRootPathString())); | |
623 | + static const RootPathCache cache(&FetchPMRResourceRef()); | |
686 | 624 | |
687 | - return path; | |
688 | -#endif | |
689 | -} | |
690 | - | |
691 | -const string& | |
692 | -FetchRootPathString() | |
693 | -{ | |
694 | - return FetchRootPathCache().PathString; | |
695 | -} | |
696 | - | |
697 | -IO::Path | |
698 | -GetLocalFHSRootPathOf(const string& path_string) | |
699 | -{ | |
700 | -#if true | |
701 | - // XXX: This is more efficient. | |
702 | - IO::Path bin(path_string); | |
703 | - auto prefix(bin / u".."); | |
704 | - | |
705 | - if(CheckLocalFHSLayoutImpl(prefix, std::move(bin))) | |
706 | - return prefix; | |
707 | -#else | |
708 | - if(CheckLocalFHSLayout(path_string)) | |
709 | - return IO::Path(path_string) / u".."; | |
710 | -#endif | |
711 | - return {}; | |
625 | + return cache; | |
712 | 626 | } |
713 | 627 | |
714 | 628 |
@@ -716,14 +630,12 @@ | ||
716 | 630 | LoadNPLA1File(const char* disp, const char* path, ValueNodeCreator creator, |
717 | 631 | ValueNode::allocator_type a, bool show_info) |
718 | 632 | { |
719 | - auto res(TryInvoke([=]() -> ValueNode{ | |
633 | + return LoadNPLA1MemoryFallback(TryInvoke([=]() -> ValueNode{ | |
720 | 634 | if(ufexists(path)) |
721 | 635 | return LoadNPLA1FileDirect(disp, path, a, show_info); |
722 | 636 | YTraceDe(Debug, "Path '%s' access failed.", path); |
723 | 637 | return LoadNPLA1FileCreate(disp, path, creator, a, show_info); |
724 | - })); | |
725 | - | |
726 | - return res ? std::move(res) : LoadNPLA1MemoryFallback(creator, a); | |
638 | + }), creator, a); | |
727 | 639 | } |
728 | 640 | |
729 | 641 | void |
@@ -761,24 +673,21 @@ | ||
761 | 673 | }); |
762 | 674 | |
763 | 675 | #if YF_Helper_Initialization_UseFallbackConf_ |
764 | - return LoadNPLA1FileVec(ConfFileDisp, FetchConfPaths(), "yconf.txt", | |
765 | - creator, a, show_info); | |
676 | + return LoadNPLA1FileVec(ConfFileDisp, "yconf.txt", creator, a, show_info); | |
766 | 677 | #else |
767 | 678 | return LoadNPLA1File(ConfFileDisp, (FetchPreferredConfPath() + "yconf.txt") |
768 | 679 | .c_str(), creator, a, show_info); |
769 | 680 | #endif |
770 | -#undef YF_Helper_Initialization_UseFallbackConf_ | |
771 | 681 | } |
772 | 682 | |
773 | 683 | void |
774 | 684 | SaveConfiguration(const ValueNode& node) |
775 | 685 | { |
776 | - if(UniqueLockedOutputFileStream uofs{ | |
777 | - (FetchConfPathForSave() + "yconf.txt").c_str(), | |
778 | - std::ios_base::out | std::ios_base::trunc}) | |
686 | + if(UniqueLockedOutputFileStream uofs{(FetchConfPathForSave() | |
687 | + + "yconf.txt").c_str(), std::ios_base::out | std::ios_base::trunc}) | |
779 | 688 | { |
780 | 689 | YTraceDe(Debug, "Writing configuration..."); |
781 | - WriteNPLA1Stream(uofs, ValueNode(node.GetContainer())); | |
690 | + WriteNPLA1StreamWithBOM(uofs, ValueNode(node.GetContainer())); | |
782 | 691 | } |
783 | 692 | else |
784 | 693 | throw GeneralEvent("Invalid file found when writing configuration."); |
@@ -788,6 +697,7 @@ | ||
788 | 697 | #undef YF_Helper_Initialization_DataDirectory_ |
789 | 698 | #undef YF_Helper_Initialization_FontDirectory_ |
790 | 699 | #undef YF_Helper_Initialization_FontFile_ |
700 | +#undef YF_Helper_Initialization_UseFallbackConf_ | |
791 | 701 | |
792 | 702 | |
793 | 703 | void |
@@ -842,11 +752,9 @@ | ||
842 | 752 | return FetchEnvironment().Root; |
843 | 753 | } |
844 | 754 | |
845 | -Drawing::FontCache& | |
755 | +FontCache& | |
846 | 756 | FetchDefaultFontCache() |
847 | 757 | { |
848 | - using Drawing::FontCache; | |
849 | - | |
850 | 758 | return FetchDefaultResource<FontCache>([]{ |
851 | 759 | return make_unique<FontCache>(+FontCache::DefaultGlyphCacheSize, |
852 | 760 | FetchAppInstance().get_allocator()); |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2010-2015, 2019-2022 FrankHB. | |
2 | + © 2010-2015, 2019-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file ShellHelper.cpp |
12 | 12 | \ingroup Helper |
13 | 13 | \brief Shell 助手模块。 |
14 | -\version r636 | |
14 | +\version r642 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 278 |
17 | 17 | \par 创建时间: |
18 | 18 | 2010-04-04 13:42:15 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-04-30 21:53 +0800 | |
20 | + 2023-12-23 16:40 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -39,7 +39,7 @@ | ||
39 | 39 | DebugTimer::DebugTimer(string_view str) |
40 | 40 | : event_info((yunused(Nonnull(str.data())), str)), base_tick() |
41 | 41 | { |
42 | - YTraceDe(0xF0, "Start tick of [%s] :", event_info.c_str()); | |
42 | + YTraceDe(0xF0, "Start tick of [%s]:", event_info.c_str()); | |
43 | 43 | base_tick = Timers::HighResolutionClock::now(); |
44 | 44 | } |
45 | 45 | DebugTimer::~DebugTimer() |
@@ -68,12 +68,12 @@ | ||
68 | 68 | namespace |
69 | 69 | { |
70 | 70 | |
71 | -//! \since build 264 | |
72 | -inline void | |
71 | +//! \since build 982 | |
72 | +YB_NONNULL(1, 4) inline void | |
73 | 73 | snftime(char* buf, size_t n, const std::tm& tm, |
74 | - const char* format = DefaultTimeFormat) | |
74 | + const char* format = DefaultTimeFormat) ynothrow | |
75 | 75 | { |
76 | - // FIXME: Correct behavior for time with BC date(i.e. tm_year < -1900). | |
76 | + // FIXME: Correct behavior for time with BC date (i.e. tm_year < -1900). | |
77 | 77 | std::snprintf(buf, n, format, tm.tm_year + 1900, |
78 | 78 | tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); |
79 | 79 | } |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2012-2016, 2020-2022 FrankHB. | |
2 | + © 2012-2016, 2020-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file Configuration.cpp |
12 | 12 | \ingroup NPL |
13 | 13 | \brief 配置设置。 |
14 | -\version r1048 | |
14 | +\version r1063 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 334 |
17 | 17 | \par 创建时间: |
18 | 18 | 2012-08-27 15:15:06 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-09-23 02:20 +0800 | |
20 | + 2023-12-20 20:32 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -28,11 +28,14 @@ | ||
28 | 28 | #include "NPL/YModules.h" |
29 | 29 | #include YFM_NPL_Configuration // for ystdex::value_or, AccessPtr, string, |
30 | 30 | // ystdex::quote, YSLib::AsNode, Deliteralize, PrintNode, |
31 | -// LiteralizeEscapeNodeLiteral; | |
31 | +// LiteralizeEscapeNodeLiteral, LoggedEvent, ystdex::sfmt, YSLib::Warning, | |
32 | +// std::exception; | |
32 | 33 | #include YFM_NPL_NPLA1Forms // for A1, Forms, RegisterStrict; |
33 | 34 | #include YFM_NPL_Dependency // for LoadGroundContext; |
34 | 35 | #include <ystdex/ios.hpp> // for ystdex::rethrow_badstate, |
35 | 36 | // std::ios_base::failbit; |
37 | +#include <ystdex/string.hpp> // for ystdex::write_literal; | |
38 | +#include YFM_YSLib_Service_TextFile // for YSLib::Text::BOM_UTF_8; | |
36 | 39 | |
37 | 40 | namespace NPL |
38 | 41 | { |
@@ -87,7 +90,7 @@ | ||
87 | 90 | auto&& node(TransformNode(tm)); |
88 | 91 | |
89 | 92 | node_con.insert(node.GetName().empty() ? YSLib::AsNode( |
90 | - node.get_allocator(), '$' + MakeIndex(node_con.size()), | |
93 | + node.get_allocator(), '$' + MakeIndex(node_con.size(), a), | |
91 | 94 | std::move(node.Value)) : std::move(node)); |
92 | 95 | }); |
93 | 96 | return {std::allocator_arg, a, std::move(node_con), name}; |
@@ -106,12 +109,12 @@ | ||
106 | 109 | NodeLoader::LoadNode(const TermNode& tree) const |
107 | 110 | { |
108 | 111 | TryRet(TransformNode(tree)) |
109 | - CatchThrow(bad_any_cast& e, LoggedEvent(YSLib::sfmt("Bad NPLA1 tree found:" | |
110 | - " cast failed from [%s] to [%s] .", e.from(), e.to()), YSLib::Warning)) | |
112 | + CatchThrow(bad_any_cast& e, LoggedEvent(ystdex::sfmt("Bad NPLA1 tree found:" | |
113 | + " cast failed from [%s] to [%s].", e.from(), e.to()), YSLib::Warning)) | |
111 | 114 | catch(std::exception& e) |
112 | 115 | { |
113 | - YTraceDe(YSLib::Err, "Bad NPLA1 tree found: [%s]%s", | |
114 | - typeid(e).name(), e.what()); | |
116 | + YTraceDe(YSLib::Err, "Bad NPLA1 tree found: [%s]%s", typeid(e).name(), | |
117 | + e.what()); | |
115 | 118 | throw; |
116 | 119 | } |
117 | 120 | } |
@@ -134,5 +137,11 @@ | ||
134 | 137 | return is; |
135 | 138 | } |
136 | 139 | |
140 | +void | |
141 | +WriteNPLA1StreamWithBOM(std::ostream& os, NPL::Configuration&& conf) | |
142 | +{ | |
143 | + ystdex::write_literal(os, YSLib::Text::BOM_UTF_8) << std::move(conf); | |
144 | +} | |
145 | + | |
137 | 146 | } // namespace NPL; |
138 | 147 |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file Dependency.cpp |
12 | 12 | \ingroup NPL |
13 | 13 | \brief 依赖管理。 |
14 | -\version r9261 | |
14 | +\version r9269 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 623 |
17 | 17 | \par 创建时间: |
18 | 18 | 2015-08-09 22:14:45 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2023-11-24 08:45 +0800 | |
20 | + 2024-02-14 00:05 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -2295,7 +2295,7 @@ | ||
2295 | 2295 | // NOTE: As %StringSplit in NPLA1Extended.cpp. |
2296 | 2296 | string::size_type pos(0), orig(0); |
2297 | 2297 | |
2298 | - while((pos = x.find('?', pos)) != string::npos) | |
2298 | + while((pos = x.find(';', pos)) != string::npos) | |
2299 | 2299 | { |
2300 | 2300 | p_vec->push_back(x.substr(orig, pos - orig)); |
2301 | 2301 | orig = ++pos; |
@@ -2345,7 +2345,7 @@ | ||
2345 | 2345 | throw NPLException( |
2346 | 2346 | "Requirement '" + to_std_string(req) + "' is not registered."); |
2347 | 2347 | }); |
2348 | - RegisterUnary<Strict, const string>(m, "find-requirement-filename", | |
2348 | + RegisterUnary<Strict, const string>(m, "find-required-filename", | |
2349 | 2349 | // TODO: Blocked. Use C++14 lambda initializers to optimize the |
2350 | 2350 | // implementation. |
2351 | 2351 | // XXX: Not using binding to prevent overloading ambiguity. |
@@ -2429,7 +2429,7 @@ | ||
2429 | 2429 | // XXX: Thread-safety is not respected currently. |
2430 | 2430 | A1::Perform(cs, R"NPL( |
2431 | 2431 | $provide/let! (registered-requirement? register-requirement! |
2432 | - unregister-requirement! find-requirement-filename require) | |
2432 | + unregister-requirement! find-required-filename require) | |
2433 | 2433 | ((mods $as-environment ( |
2434 | 2434 | $import&! std.strings string-empty? ++ string->symbol; |
2435 | 2435 |
@@ -2450,7 +2450,7 @@ | ||
2450 | 2450 | (($remote-eval% string-split std.strings) spec ";"), |
2451 | 2451 | ( |
2452 | 2452 | $def! placeholder ($remote-eval% string->regex std.strings) "\?", |
2453 | - $defl! get-requirement-filename (&specs &req) | |
2453 | + $defl! get-required-filename (&specs &req) | |
2454 | 2454 | $if (null? specs) |
2455 | 2455 | (raise-error (++ "No module for requirement '" req |
2456 | 2456 | "' found.")) |
@@ -2458,7 +2458,7 @@ | ||
2458 | 2458 | $let* ((spec first& specs) (path ($remote-eval% regex-replace |
2459 | 2459 | std.strings) spec placeholder req)) |
2460 | 2460 | $if (($remote-eval% readable-file? std.io) path) path |
2461 | - (get-requirement-filename (rest& specs) req) | |
2461 | + (get-required-filename (rest& specs) req) | |
2462 | 2462 | ) |
2463 | 2463 | ) |
2464 | 2464 | ))) |
@@ -2476,12 +2476,12 @@ | ||
2476 | 2476 | $if (string-empty? req) (() requirement-error) |
2477 | 2477 | ($if (bound-name? req) (set-value! req ()) (raise-error |
2478 | 2478 | (++ "Requirement '" req "' is not registered."))), |
2479 | - $defl/e! &find-requirement-filename mods (&req) | |
2480 | - get-requirement-filename | |
2479 | + $defl/e! &find-required-filename mods (&req) | |
2480 | + get-required-filename | |
2481 | 2481 | (($remote-eval% force std.promises) prom_pathspecs) req; |
2482 | 2482 | $defl/e%! require mods (&req .&opt) |
2483 | 2483 | $if (registered-requirement? req) (get-cell% (forward! req)) |
2484 | - ($let*% ((filename find-requirement-filename req) | |
2484 | + ($let*% ((filename find-required-filename req) | |
2485 | 2485 | (env register-requirement! req) (&res get-cell% (forward! req))) |
2486 | 2486 | $sequence |
2487 | 2487 | ($unless (null? opt) |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2015-2017, 2019-2020, 2022 FrankHB. | |
2 | + © 2015-2017, 2019-2020, 2022-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file SXML.cpp |
12 | 12 | \ingroup NPL |
13 | 13 | \brief NPL SXML 实现。 |
14 | -\version r4735 | |
14 | +\version r4737 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 936 |
17 | 17 | \par 创建时间: |
18 | 18 | 2022-01-20 17:41:15 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-06-14 18:34 +0800 | |
20 | + 2023-12-23 16:36 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -69,7 +69,7 @@ | ||
69 | 69 | { |
70 | 70 | if(term) |
71 | 71 | { |
72 | - string res(ConvertStringNode(term)); | |
72 | + auto res(ConvertStringNode(term)); | |
73 | 73 | |
74 | 74 | if(res.empty()) |
75 | 75 | { |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2009-2016, 2018, 2021 FrankHB. | |
2 | + © 2009-2016, 2018, 2021, 2024 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file Keys.cpp |
12 | 12 | \ingroup YCLib |
13 | 13 | \brief 平台相关的基本按键输入定义。 |
14 | -\version r1279 | |
14 | +\version r1283 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 313 |
17 | 17 | \par 创建时间: |
18 | 18 | 2012-06-01 14:32:37 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2021-12-29 01:49 +0800 | |
20 | + 2024-02-26 05:47 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -26,10 +26,9 @@ | ||
26 | 26 | |
27 | 27 | |
28 | 28 | #include "YCLib/YModules.h" |
29 | -#include YFM_YCLib_Keys // for octet; | |
29 | +#include YFM_YCLib_Keys // for size, octet; | |
30 | 30 | #include YFM_YCLib_Debug |
31 | 31 | #include YFM_YCLib_NativeAPI |
32 | -#include YFM_YCLib_Container // for size; | |
33 | 32 | |
34 | 33 | namespace platform |
35 | 34 | { |
@@ -115,7 +114,7 @@ | ||
115 | 114 | Editing | NonKeyboard // Extended tertiary key. |
116 | 115 | }; |
117 | 116 | #elif YCL_Win32 |
118 | -// See http://msdn.microsoft.com/library/windows/desktop/dd375731%28v=vs.85%29.aspx. | |
117 | +// See https://msdn.microsoft.com/library/windows/desktop/dd375731.aspx. | |
119 | 118 | yconstexpr const Category KeyCategoryTable[KeyBitsetWidth]{ |
120 | 119 | None, // 0 is not assigned. |
121 | 120 | Editing | NonKeyboard, // VK_LBUTTON is a mouse key. |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2014-2016, 2018, 2020, 2023 FrankHB. | |
2 | + © 2014-2016, 2018, 2020, 2023-2024 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -12,13 +12,13 @@ | ||
12 | 12 | \ingroup YCLib |
13 | 13 | \ingroup YCLibLimitedPlatforms |
14 | 14 | \brief XCB GUI 接口。 |
15 | -\version r614 | |
15 | +\version r622 | |
16 | 16 | \author FrankHB <frankhb1989@gmail.com> |
17 | 17 | \since build 427 |
18 | 18 | \par 创建时间: |
19 | 19 | 2014-12-14 14:14:31 +0800 |
20 | 20 | \par 修改时间: |
21 | - 2023-05-07 04:16 +0800 | |
21 | + 2024-02-25 23:10 +0800 | |
22 | 22 | \par 文本编码: |
23 | 23 | UTF-8 |
24 | 24 | \par 模块名称: |
@@ -27,12 +27,12 @@ | ||
27 | 27 | |
28 | 28 | |
29 | 29 | #include "YCLib/YModules.h" |
30 | -#include YFM_YCLib_Platform // for YSLib::Drawing, YSLib::RecordLevel, | |
31 | -// YSLib::Err, YSLib::Informative, platform::Deref, platform::Nonnull, | |
32 | -// ordered_linked_map, YTraceDe; | |
30 | +#include YFM_YCLib_Platform // for platform::Nonnull; | |
33 | 31 | #if YF_Use_XCB |
32 | +# include YFM_YCLib_XCB // for YSLib::Drawing, YSLib::RecordLevel, YSLib::Err, | |
33 | +// YSLib::Informative, platform::Deref, ordered_linked_map, YTraceDe, | |
34 | +// YSLib::FilterExceptions; | |
34 | 35 | # include <ystdex/array.hpp> // for ystdex::cast_array; |
35 | -# include YFM_YCLib_XCB // for YSLib::FilterExceptions; | |
36 | 36 | # include YFM_YCLib_Mutex // for platform::Concurrency, platform::Threading; |
37 | 37 | # include <xcb/xcb.h> // for ::uint32_t, ::uint8_t; |
38 | 38 | # include <ystdex/addressof.hpp> // for ystdex::pvoid; |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2009-2016, 2020-2022 FrankHB. | |
2 | + © 2009-2016, 2020-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file YApplication.cpp |
12 | 12 | \ingroup Core |
13 | 13 | \brief 系统资源和应用程序实例抽象。 |
14 | -\version r1757 | |
14 | +\version r1776 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since 早于 build 132 |
17 | 17 | \par 创建时间: |
18 | 18 | 2009-12-27 17:12:36 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-09-03 21:39 +0800 | |
20 | + 2023-12-23 16:41 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -43,16 +43,19 @@ | ||
43 | 43 | { |
44 | 44 | // See $2020-04 @ %Documentation::Workflow. |
45 | 45 | qMain.clear(); |
46 | - if(YB_UNLIKELY(hShell)) | |
46 | + if(!hShell) | |
47 | + { | |
48 | + hShell = {}; | |
49 | + YTraceDe(Notice, "Deinitialization entered with %zu handler(s) to be" | |
50 | + " called.", on_exit.size()); | |
51 | + // NOTE: This is needed because the standard containers (and adaptors) | |
52 | + // guarantee nothing about destruction order of contained elements. | |
53 | + while(!on_exit.empty()) | |
54 | + on_exit.pop(); | |
55 | + } | |
56 | + else | |
47 | 57 | YTraceDe(Warning, "Active shell found with count %ld.", |
48 | 58 | hShell.use_count()); |
49 | - hShell = {}; | |
50 | - YTraceDe(Notice, "Deinitialization entered with %zu handler(s) to be" | |
51 | - " called.", on_exit.size()); | |
52 | - // NOTE: This is needed because the standard containers (and adaptors) | |
53 | - // guarantee nothing about destruction order of contained elements. | |
54 | - while(!on_exit.empty()) | |
55 | - on_exit.pop(); | |
56 | 59 | } |
57 | 60 | |
58 | 61 | void |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2009-2013, 2015-2017, 2019-2022 FrankHB. | |
2 | + © 2009-2013, 2015-2017, 2019-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file YObject.cpp |
12 | 12 | \ingroup Core |
13 | 13 | \brief 平台无关的基础对象。 |
14 | -\version r923 | |
14 | +\version r927 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since 早于 build 132 |
17 | 17 | \par 创建时间: |
18 | 18 | 2009-11-16 20:06:58 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-11-28 19:53 +0800 | |
20 | + 2023-12-20 20:31 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -75,9 +75,9 @@ | ||
75 | 75 | { |
76 | 76 | const auto p_holder(content.get_holder()); |
77 | 77 | |
78 | - if(const auto q = x.content.get_holder()) | |
79 | - return p_holder == q || (p_holder && p_holder->type() == q->type() | |
80 | - && HolderEquals(*p_holder, q->get())); | |
78 | + if(const auto q_holder = x.content.get_holder()) | |
79 | + return p_holder == q_holder || (p_holder && p_holder->type() | |
80 | + == q_holder->type() && HolderEquals(*p_holder, q_holder->get())); | |
81 | 81 | return !p_holder; |
82 | 82 | } |
83 | 83 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2010-2016, 2019-2023 FrankHB. | |
2 | + © 2010-2016, 2019-2024 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file FileSystem.cpp |
12 | 12 | \ingroup Service |
13 | 13 | \brief 平台中立的文件系统抽象。 |
14 | -\version r2436 | |
14 | +\version r2502 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since 早于 build 132 |
17 | 17 | \par 创建时间: |
18 | 18 | 2010-03-28 00:36:30 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2023-10-02 16:48 +0800 | |
20 | + 2024-02-25 02:41 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -28,11 +28,13 @@ | ||
28 | 28 | #include "YSLib/Service/YModules.h" |
29 | 29 | #include YFM_YSLib_Service_FileSystem // for FetchCurrentWorkingDirectory, |
30 | 30 | // IsAbsolute, DirectorySession, umkdir, MakeMBCS, FetchSeparator, |
31 | -// use_openmode_t, IsDirectory; | |
31 | +// use_openmode_t, IsDirectory, IO::EndsWithNonSeperator; | |
32 | 32 | #include <ios> // for std::ios_base::in, std::ios_base::binary; |
33 | 33 | #include <cerrno> // for errno, EEXIST; |
34 | 34 | #include <ystdex/exception.h> // for std::system_error, ystdex::throw_error; |
35 | 35 | #include YFM_YSLib_Service_File // for OpenFile; |
36 | +#include YFM_YSLib_Core_YStorage // for FetchStaticRef; | |
37 | +#include <ystdex/string.hpp> // for ystdex::rtrim; | |
36 | 38 | |
37 | 39 | namespace YSLib |
38 | 40 | { |
@@ -276,6 +278,79 @@ | ||
276 | 278 | |
277 | 279 | } // unnamed namespace; |
278 | 280 | |
281 | +bool | |
282 | +CheckLocalFHSLayout(const IO::Path& pfx, IO::Path bin) | |
283 | +{ | |
284 | + if(bin != pfx) | |
285 | + { | |
286 | + const IO::Path | |
287 | + paths[]{pfx, std::move(bin), pfx / u"lib", pfx / u"share"}; | |
288 | + | |
289 | + return IO::VerifyDirectories(paths); | |
290 | + } | |
291 | + return {}; | |
292 | +} | |
293 | +bool | |
294 | +CheckLocalFHSLayout(const string& path) | |
295 | +{ | |
296 | + IO::Path bin(path, path.get_allocator()); | |
297 | + const auto pfx(bin / u".."); | |
298 | + | |
299 | + return CheckLocalFHSLayout(pfx, std::move(bin)); | |
300 | +} | |
301 | + | |
302 | +IO::Path | |
303 | +GetLocalFHSRootPathOf(const string& path) | |
304 | +{ | |
305 | +#if true | |
306 | + // XXX: This is more efficient. | |
307 | + IO::Path bin(path, path.get_allocator()); | |
308 | + auto prefix(bin / u".."); | |
309 | + | |
310 | + if(Deployment::CheckLocalFHSLayout(prefix, std::move(bin))) | |
311 | + return prefix; | |
312 | +#else | |
313 | + if(Deployment::CheckLocalFHSLayout(path)) | |
314 | + return IO::Path(path, path.get_allocator()) / u".."; | |
315 | +#endif | |
316 | + return {}; | |
317 | +} | |
318 | + | |
319 | + | |
320 | +const IO::Path& | |
321 | +RootPathBlock::GetSavedLocalFHSRootPath() const | |
322 | +{ | |
323 | + // XXX: This is more efficient than | |
324 | + // 'Deployment::GetLocalFHSRootPathOf(saved)' cached in static storage | |
325 | + // (with some default allocator). | |
326 | + return HasLocalFHSLayout() ? parent : FetchStaticRef<const IO::Path>(); | |
327 | +} | |
328 | + | |
329 | +bool | |
330 | +RootPathBlock::HasLocalFHSLayout() const | |
331 | +{ | |
332 | +# if true | |
333 | + // XXX: This is more efficient. | |
334 | + return CheckLocalFHSLayout(parent, current); | |
335 | +# else | |
336 | + return CheckLocalFHSLayout(saved); | |
337 | +# endif | |
338 | +} | |
339 | + | |
340 | +string | |
341 | +RootPathBlock::FetchCurrentWorkingDirectoryPath(string::allocator_type a) | |
342 | +{ | |
343 | + // XXX: Trimming is necessary, because it is unspecified to have trailing | |
344 | + // slashes with %platform::ugetcwd as POSIX.1 2004. | |
345 | + auto res(ystdex::rtrim(FetchCurrentWorkingDirectory<char>( | |
346 | + IO::MaxPathLength, a), IO::FetchSeparator<char>())); | |
347 | + | |
348 | + YAssert(IO::EndsWithNonSeperator(res), "Invalid argument found."); | |
349 | + res += IO::FetchSeparator<char>(); | |
350 | + return res; | |
351 | +} | |
352 | + | |
353 | + | |
279 | 354 | void |
280 | 355 | InstallFile(const char* dst, const char* src) |
281 | 356 | { |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2014-2015, 2021-2022 FrankHB. | |
2 | + © 2014-2015, 2021-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file ImageProcessing.cpp |
12 | 12 | \ingroup Service |
13 | 13 | \brief 图像处理。 |
14 | -\version r287 | |
14 | +\version r290 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 554 |
17 | 17 | \par 创建时间: |
18 | 18 | 2014-11-16 16:37:27 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-04-30 21:54 +0800 | |
20 | + 2023-12-23 16:19 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -27,6 +27,7 @@ | ||
27 | 27 | |
28 | 28 | #include "YSLib/UI/YModules.h" |
29 | 29 | #include YFM_YSLib_Service_ImageProcessing |
30 | +#include <ystdex/cache.hpp> // for ystdex::cache_lookup; | |
30 | 31 | |
31 | 32 | namespace YSLib |
32 | 33 | { |
@@ -63,7 +64,7 @@ | ||
63 | 64 | YAssert(idx < bitmaps.size(), "Invalid index found."); |
64 | 65 | |
65 | 66 | return ystdex::cache_lookup(cache, CacheKey(scale, idx), [&]{ |
66 | - return make_shared<Image>(Zoom(bitmaps[idx], scale)); | |
67 | + return YSLib::make_shared<Image>(Zoom(bitmaps[idx], scale)); | |
67 | 68 | }); |
68 | 69 | } |
69 | 70 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2009-2015, 2017, 2019, 2022 FrankHB. | |
2 | + © 2009-2015, 2017, 2019, 2022-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file TextRenderer.cpp |
12 | 12 | \ingroup Service |
13 | 13 | \brief 文本渲染。 |
14 | -\version r2768 | |
14 | +\version r2770 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 275 |
17 | 17 | \par 创建时间: |
18 | 18 | 2009-11-13 00:06:05 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-04-30 21:55 +0800 | |
20 | + 2023-12-23 16:25 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -31,8 +31,6 @@ | ||
31 | 31 | #include YFM_YSLib_Service_TextLayout // for FetchLastLineBasePosition; |
32 | 32 | #include <ystdex/cwctype.h> // for ystdex::iswgraph; |
33 | 33 | |
34 | -using namespace ystdex; | |
35 | - | |
36 | 34 | namespace YSLib |
37 | 35 | { |
38 | 36 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2015, 2022 FrankHB. | |
2 | + © 2015, 2022-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file YBlend.cpp |
12 | 12 | \ingroup Service |
13 | 13 | \brief 平台无关的图像块操作。 |
14 | -\version r59 | |
14 | +\version r61 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 584 |
17 | 17 | \par 创建时间: |
18 | 18 | 2015-03-17 06:19:55 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-04-30 21:56 +0800 | |
20 | + 2023-12-23 16:24 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -28,8 +28,6 @@ | ||
28 | 28 | #include "YSLib/Service/YModules.h" |
29 | 29 | #include YFM_YSLib_Service_YBlend |
30 | 30 | |
31 | -using namespace ystdex; | |
32 | - | |
33 | 31 | namespace YSLib |
34 | 32 | { |
35 | 33 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2011-2016, 2019, 2022 FrankHB. | |
2 | + © 2011-2016, 2019, 2022-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file YDraw.cpp |
12 | 12 | \ingroup Service |
13 | 13 | \brief 平台无关的二维图形光栅化。 |
14 | -\version r1120 | |
14 | +\version r1134 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 219 |
17 | 17 | \par 创建时间: |
18 | 18 | 2011-06-16 19:45:33 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-04-30 21:56 +0800 | |
20 | + 2023-12-23 16:22 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -93,12 +93,9 @@ | ||
93 | 93 | PlotVLineSeg(dst, bounds, w, x1, y1, y2 + 1, c); |
94 | 94 | else |
95 | 95 | { |
96 | - /* | |
97 | - 一般 Bresenham 算法:实现自 | |
98 | - http://cg.sjtu.edu.cn/lecture_site/chap2/mainframe212.htm 伪代码。 | |
99 | - */ | |
100 | - //起点 (x1, y1) 和终点 (x2, y2) 不同。 | |
101 | - | |
96 | + // NOTE: General Bresenham's algorithm: from | |
97 | + // http://cg.sjtu.edu.cn/lecture_site/chap2/mainframe212.htm. The | |
98 | + // points (x1, y1) and (x2, y2) shall be different. | |
102 | 99 | const std::int8_t sx(FetchSign(x2 - x1)), sy(FetchSign(y2 - y1)); |
103 | 100 | SDst dx(SDst(abs(x2 - x1))), dy(SDst(abs(y2 - y1))); |
104 | 101 | bool f(dy > dx); |
@@ -106,12 +103,11 @@ | ||
106 | 103 | if(f) |
107 | 104 | std::swap(dx, dy); |
108 | 105 | |
109 | - //初始化误差项以补偿非零截断。 | |
106 | + // NOTE: Initialize error term to make up the non-zero trucations. | |
110 | 107 | // XXX: Conversion to 'SPos' might be implementation-defined. |
111 | 108 | const SPos dx2(SPos(dx << 1)), dy2(SPos(dy << 1)); |
112 | 109 | SPos e(dy2 - SPos(dx)); |
113 | 110 | |
114 | - //主循环。 | |
115 | 111 | while(dx-- != 0) |
116 | 112 | { |
117 | 113 | PlotPixel(dst, bounds, w, x1, y1, c); |
@@ -166,8 +162,8 @@ | ||
166 | 162 | YAssert(bounds.IsUnstrictlyEmpty() || Rect(g.GetSize()).Contains(bounds), |
167 | 163 | "The boundary is out of the buffer."); |
168 | 164 | if(r != 0) |
169 | - // Bresenham circle algorithm implementation. | |
170 | - // See http://willperone.net/Code/codecircle.php. | |
165 | + // NOTE: Bresenham's circle algorithm implementation. See | |
166 | + // http://willperone.net/Code/codecircle.php. | |
171 | 167 | // XXX: Conversion to 'SPos' might be implementation-defined. |
172 | 168 | for(SPos x(0), y((SPos(r))), p(SPos(3 - 2 * r)); y >= x; |
173 | 169 | p += p < 0 ? (4 * x++ + 6) : (4 * (x++ - y--) + 10)) |
@@ -204,10 +200,9 @@ | ||
204 | 200 | { |
205 | 201 | PlotCircle([](const Graphics& g, const Rect& bounds, SPos x, SPos y, |
206 | 202 | SPos dx, SPos dy, Color c){ |
207 | - using namespace std; | |
208 | - using namespace placeholders; | |
209 | - const auto plot(bind(PlotHLineSeg, g.GetBufferPtr(), std::cref(bounds), | |
210 | - g.GetWidth(), _1, _2, _3, c)); | |
203 | + using namespace std::placeholders; | |
204 | + const auto plot(std::bind(PlotHLineSeg, g.GetBufferPtr(), | |
205 | + std::cref(bounds), g.GetWidth(), _1, _2, _3, c)); | |
211 | 206 | |
212 | 207 | plot(y + dy, x - dx, x + dx + 1), |
213 | 208 | plot(y - dy, x - dx, x + dx + 1), |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2013-2016, 2018-2022 FrankHB. | |
2 | + © 2013-2016, 2018-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file Loader.cpp |
12 | 12 | \ingroup UI |
13 | 13 | \brief 动态 GUI 加载。 |
14 | -\version r395 | |
14 | +\version r400 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 433 |
17 | 17 | \par 创建时间: |
18 | 18 | 2013-08-01 20:39:49 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-09-22 23:36 +0800 | |
20 | + 2023-12-23 16:47 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -27,7 +27,8 @@ | ||
27 | 27 | |
28 | 28 | #include "YSLib/UI/YModules.h" |
29 | 29 | #include YFM_YSLib_UI_Loader // for to_std_string, istringtream, |
30 | -// std::allocator_arg, shared_ptr; | |
30 | +// std::invalid_argument, to_string, std::allocator_arg, Deref, Access, | |
31 | +// shared_ptr; | |
31 | 32 | #include <sstream> // for complete istringtream; |
32 | 33 | #include <limits> // for std::numeric_limits; |
33 | 34 |
@@ -104,7 +105,7 @@ | ||
104 | 105 | { |
105 | 106 | if(unique_ptr<IWidget> p_new_widget{DetectWidgetNode(node)}) |
106 | 107 | { |
107 | - ValueNode res(AsNode(node.GetName())); | |
108 | + auto res(YSLib::AsNode(node.GetName())); | |
108 | 109 | const auto& key(AccessChild<string>(node, "$type")); |
109 | 110 | const bool ins(Insert.Contains(key)); |
110 | 111 | const bool insz(InsertZOrdered.Contains(key)); |
@@ -134,7 +135,7 @@ | ||
134 | 135 | r(std::stoul(to_std_string(*p_z))); |
135 | 136 | |
136 | 137 | if(r <= std::numeric_limits<ZOrder>::max()) |
137 | - z = r; | |
138 | + z = ZOrder(r); | |
138 | 139 | } |
139 | 140 | CatchIgnore(std::invalid_argument&) |
140 | 141 | if(node_con.insert(std::move(child)).second) |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2011-2016, 2021-2022 FrankHB. | |
2 | + © 2011-2016, 2021-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file YUIContainer.cpp |
12 | 12 | \ingroup UI |
13 | 13 | \brief 样式无关的 GUI 容器。 |
14 | -\version r1947 | |
14 | +\version r1956 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 188 |
17 | 17 | \par 创建时间: |
18 | 18 | 2011-01-22 08:03:49 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-11-28 18:59 +0800 | |
20 | + 2023-12-23 16:14 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -26,8 +26,10 @@ | ||
26 | 26 | |
27 | 27 | |
28 | 28 | #include "YSLib/UI/YModules.h" |
29 | -#include YFM_YSLib_UI_YDesktop | |
29 | +#include YFM_YSLib_UI_YDesktop // for YSLib::make_observer; | |
30 | +#include <ystdex/ref.hpp> // for ystdex::ref; | |
30 | 31 | #include <ystdex/bind.hpp> // for ystdex::bind1; |
32 | +#include <algorithm> // for std::count_if, std::find_if; | |
31 | 33 | |
32 | 34 | using namespace ystdex; |
33 | 35 |
@@ -65,7 +67,7 @@ | ||
65 | 67 | vector<pair<observer_ptr<const IWidget>, Point>> lst; |
66 | 68 | Point pt; |
67 | 69 | |
68 | - for(auto p_wgt(make_observer(&wgt)); p_wgt; | |
70 | + for(auto p_wgt(YSLib::make_observer(&wgt)); p_wgt; | |
69 | 71 | p_wgt = FetchContainerPtr(*p_wgt)) |
70 | 72 | { |
71 | 73 | lst.emplace_back(p_wgt, pt); |
@@ -102,7 +104,7 @@ | ||
102 | 104 | { |
103 | 105 | Point pt; |
104 | 106 | |
105 | - for(auto p_wgt(make_observer(&wgt)); p_wgt; | |
107 | + for(auto p_wgt(YSLib::make_observer(&wgt)); p_wgt; | |
106 | 108 | p_wgt = FetchContainerPtr(*p_wgt)) |
107 | 109 | { |
108 | 110 | const auto |
@@ -186,7 +188,7 @@ | ||
186 | 188 | { |
187 | 189 | auto t(vWidgets.size()); |
188 | 190 | |
189 | - erase_all_if(vWidgets, bind1(is_equal(), std::ref(wgt))); | |
191 | + erase_all_if(vWidgets, ystdex::bind1(is_equal(), std::ref(wgt))); | |
190 | 192 | t -= vWidgets.size(); |
191 | 193 | YAssert(t <= 1, "Duplicate widget references found."); |
192 | 194 | return t != 0; |
@@ -196,14 +198,14 @@ | ||
196 | 198 | MLinearUIContainer::Contains(IWidget& wgt) const |
197 | 199 | { |
198 | 200 | return std::count_if(vWidgets.cbegin(), vWidgets.cend(), |
199 | - bind1(is_equal(), std::ref(wgt))) != 0; | |
201 | + ystdex::bind1(is_equal(), std::ref(wgt))) != 0; | |
200 | 202 | } |
201 | 203 | |
202 | 204 | size_t |
203 | 205 | MLinearUIContainer::Find(IWidget& wgt) const |
204 | 206 | { |
205 | 207 | return size_t(std::find_if(vWidgets.cbegin(), vWidgets.cend(), |
206 | - bind1(is_equal(), std::ref(wgt))) - vWidgets.cbegin()); | |
208 | + ystdex::bind1(is_equal(), std::ref(wgt))) - vWidgets.cbegin()); | |
207 | 209 | } |
208 | 210 | |
209 | 211 | MLinearUIContainer::iterator |
@@ -1,5 +1,5 @@ | ||
1 | 1 | # |
2 | -# (C) 2009-2021 FrankHB. | |
2 | +# (C) 2009-2024 FrankHB. | |
3 | 3 | # |
4 | 4 | # This file is part of the YSLib project, and may only be used, |
5 | 5 | # modified, and distributed under the terms of the YSLib project |
@@ -8,9 +8,9 @@ | ||
8 | 8 | # understand and accept it fully. |
9 | 9 | # |
10 | 10 | # DS Makefile for YSTest by FrankHB |
11 | -# Version = r1227 | |
11 | +# Version = r1229 | |
12 | 12 | # Created = 2009-11-12 21:26:30 +0800 |
13 | -# Updated = 2021-10-23 17:43 +0800 | |
13 | +# Updated = 2024-02-27 00:24 +0800 | |
14 | 14 | # Encoding = ANSI |
15 | 15 | |
16 | 16 |
@@ -46,7 +46,7 @@ | ||
46 | 46 | |
47 | 47 | TITLE := $(PROJNAME) |
48 | 48 | SUBTITLE1 := FrankHB |
49 | -SUBTITLE2 := 2009-2020 | |
49 | +SUBTITLE2 := 2009-2024 | |
50 | 50 | ICON := -b $(CURDIR)/data/logo.bmp |
51 | 51 | |
52 | 52 | ARM7ELF := $(BUILDDIR)/../../$(TARGET)_ARM7/$(CONF)/$(TARGET)_ARM7.arm7.elf |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2012-2016, 2019, 2021-2023 FrankHB. | |
2 | + © 2012-2016, 2019, 2021-2024 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file About.cpp |
12 | 12 | \ingroup YReader |
13 | 13 | \brief 关于界面。 |
14 | -\version r291 | |
14 | +\version r293 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 390 |
17 | 17 | \par 创建时间: |
18 | 18 | 2013-03-20 21:06:35 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2023-04-05 04:18 +0800 | |
20 | + 2024-02-27 00:26 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -80,7 +80,7 @@ | ||
80 | 80 | + String(p, lblVersion.Text.get_allocator()), |
81 | 81 | lblVersion.ForeColor = ColorSpace::Green, |
82 | 82 | lblCopyright.Background = nullptr, |
83 | - lblCopyright.Text = String("(C)2009-2023 by ") + G_COMP_NAME, | |
83 | + lblCopyright.Text = String("(C)2009-2024 by ") + G_COMP_NAME, | |
84 | 84 | lblCopyright.ForeColor = ColorSpace::Maroon, |
85 | 85 | btnSysInfo.Text = u"系统信息", |
86 | 86 | btnExit.Text = u"退出", |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2009-2016, 2018, 2020, 2022 FrankHB. | |
2 | + © 2009-2016, 2018, 2020, 2022-2023 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file Main.cpp |
12 | 12 | \ingroup DS |
13 | 13 | \brief 主源文件。 |
14 | -\version r1986 | |
14 | +\version r1990 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 1 |
17 | 17 | \par 创建时间: |
18 | 18 | 2009-11-12 21:26:30 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2022-11-28 14:56 +0800 | |
20 | + 2023-12-20 01:22 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -131,8 +131,8 @@ | ||
131 | 131 | |
132 | 132 | |
133 | 133 | //! 非 YSLib 声明的平台相关函数。 |
134 | -//@{ | |
135 | -//@} | |
134 | +//!@{ | |
135 | +//!@} | |
136 | 136 | |
137 | 137 | } // namespace YSLib; |
138 | 138 |
@@ -192,7 +192,7 @@ | ||
192 | 192 | } |
193 | 193 | YTraceDe(Debug, "Splash completed."); |
194 | 194 | Execute(app, make_shared<YReader::ShlExplorer>()); |
195 | - //释放 Shell (必要,保证释放 Shell 且避免资源泄漏)。 | |
195 | + //释放 Shell(必要,保证释放 Shell 且避免资源泄漏)。 | |
196 | 196 | YReader::Cleanup(); |
197 | 197 | } |
198 | 198 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2020-2023 FrankHB. | |
2 | + © 2020-2024 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file ChangeLog.V0.9.txt |
12 | 12 | \ingroup Documentation |
13 | 13 | \brief 版本更新历史记录 - V0.9 。 |
14 | -\version r20217 | |
14 | +\version r20486 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 900 |
17 | 17 | \par 创建时间: |
18 | 18 | 2020-10-12 17:19:23 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2023-12-20 00:27 +0800 | |
20 | + 2024-02-27 00:28 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -32,6 +32,275 @@ | ||
32 | 32 | |
33 | 33 | $now |
34 | 34 | ( |
35 | + / %YBase $= | |
36 | + ( | |
37 | + / %YStandardEx $= | |
38 | + ( | |
39 | + + $re_add(b973) DD "'\ingroup hashers'" @ "Doxygen comment" | |
40 | + @ ("class template specialization %std::hash for %fixed_point \ | |
41 | + instances" @ %Rational, "class template specialization \ | |
42 | + %std::hash for %type_id" @ %TypeIndex), | |
43 | + / $re_add(b981) DLDI "all '::value' not forming an operand to an \ | |
44 | + operator and not after a qualified type-id" @ "non-type \ | |
45 | + argument of some metafunctions" -> '{}' | |
46 | + @ ("function template %is_zero#1", ("constructor#(3, 4, 5, 6)", | |
47 | + "all 2 function template %operator _type") | |
48 | + @ "class template %fixed_point", | |
49 | + $impl "macros %(YB_Impl_Rational_fp_TmplHead_2_l, \ | |
50 | + YB_Impl_Rational_fp_TmplHead_2_r)") @ %Rational, | |
51 | + / $re_add(b961) DLDI "all %_tState" @ %FunctionAdaptor => "%_tCond" | |
52 | + $effective @ "%one_shot", | |
53 | + // To be consistent with %state_guard, as the change made in \ | |
54 | + %ScopeGuard. | |
55 | + / $re_add(b980) DLDI "simplified condition" | |
56 | + @ "static function template %are_equal" @ "struct %always_equal" | |
57 | + @ %Examiner !^ '&&', | |
58 | + / %Functional $= | |
59 | + ( | |
60 | + + "conditionally defined macro %__cpp_lib_not_fn", | |
61 | + + "class template %not_fn_t"; | |
62 | + + "function template %not_fn" | |
63 | + ), | |
64 | + * DD "wrong '\param' command" @ "Doxygen comment" | |
65 | + @ "function tempalte %construct_default_in" | |
66 | + @ %Placement $since b716, | |
67 | + / DLDI "member function %details::list_node_base::swap" @ %NodeBase | |
68 | + !^ "nested '=' expressions" | |
69 | + ), | |
70 | + * "missing inclusion %YBase.YStandardEx.CStandardDefinition" | |
71 | + @ %YTest.Timing $since b933 | |
72 | + // For %ystdex::size_t. | |
73 | + $= (/ $impl "header inclusion %YBase.YDefinition" | |
74 | + -> "%YBase.YStandardEx.CStandardDefinition") | |
75 | + ), | |
76 | + / DLDI "all parameter 'hShl'" => 'h' $effective @ ("function %Activate" | |
77 | + @ %YSLib.Core.YApplication, @ "functions %(IsNowShell, NowShellTo, \ | |
78 | + SetShellTo)" @ %Helper.ShellHelper) @ %YFramework, | |
79 | + / $re_add(b981) DLDI "all '::value' not forming an operand to an operator \ | |
80 | + and not after a qualified type-id in class scope" @ "other value \ | |
81 | + contexts" -> '()' @ %(YBase.YStandardEx.(Memory, Tuple), | |
82 | + YFramework.($impl 'YCLib(DS)'.DSIO, CHRLib.StaticMapping)), | |
83 | + / "simplified operand of 'noexcept' without '&&'" ^ 'ynoexcept_spec' | |
84 | + ~ ('ynoexcept', 'noexcept') | |
85 | + $effective @ %YBase.YSatandardEx.FunctionAdaptor, | |
86 | + / %YFramework $= | |
87 | + ( | |
88 | + / @ "functions %(MakeUCS2LE, MakeUCS4LE)" @ %CHRLib.CharacterProcessing | |
89 | + $= | |
90 | + ( | |
91 | + / "initialization of result" @ "overload with string view and \ | |
92 | + encoding" ^ "explicit construction" ~ "initializer-list", | |
93 | + // This supports explicit constructors, making it more \ | |
94 | + consistent to other overloads. | |
95 | + / "overloads with string view, encoding and probably allocator" | |
96 | + ^ 'yconstfn' ~ 'inline' | |
97 | + ), | |
98 | + + $re_add(b981) $dev $lib 'YB_ATTR_nodiscard' @ "all definitions with \ | |
99 | + %DefGetter not already having 'YB_ATTR_nodiscard'" | |
100 | + @ %(Helper.ShellHelper, NPL.Configuration, YCLib.XCB, | |
101 | + YSLib.(Core.(YApplication, YDevice, YException), | |
102 | + Service.(ImageProcessing, YGDI), UI.(YControl, YUIContainer))), | |
103 | + / DLI "platform %Win32" @ %'Helper_(DS)'.DSMain ^ 'std::uint16_t' | |
104 | + ~ 'double', | |
105 | + - "header inclusion %YCLib.Debug" @ %Helper.ShellHelper, | |
106 | + / %NPL $= | |
107 | + ( | |
108 | + / %Configuration $= | |
109 | + ( | |
110 | + / DLI "call to %MakeIndex" @ "function %TransformNode" | |
111 | + ^ "allocator", | |
112 | + / DLI "member function %NodeLoader::LoadNode" ^ "%ystdex::sfmt" | |
113 | + ~ "%YSLib::sfmt", | |
114 | + // This avoids implicit default-initialized PMR allocator. | |
115 | + / "minor space removal" @ "exception message" | |
116 | + @ "member fnction %NodeLoader::LoadNode" | |
117 | + ), | |
118 | + / DLDI "simplified function %ConvertDocumentNode" @ %SXML | |
119 | + ^ 'auto' ~ 'string', | |
120 | + / @ "function %LoadModule_std_modules" @ %Dependency $= | |
121 | + ( | |
122 | + * "incorrect template string sequence from the non-empty value \ | |
123 | + of environment variable %NPLA1_PATH split by '?' instead \ | |
124 | + of ';'" @ "native implementation" @ "applicatives \ | |
125 | + ('find-requirement-filename', 'require')" $since b923; | |
126 | + / "applicative 'find-requirement-filename'" | |
127 | + => 'file-required-filename' | |
128 | + // This is more consistent to klisp. | |
129 | + ) | |
130 | + ), | |
131 | + / %YCLib $= | |
132 | + ( | |
133 | + / $dev $lib @ 'YF_Use_XCB' @ %XCB $= | |
134 | + ( | |
135 | + + $re_add(b981) 'YB_ATTR_nodiscard' | |
136 | + @ ("all definitions with %DefBoolNeg", "all definitions \ | |
137 | + with %DefCvt", "all definitions with %DefPred"), | |
138 | + - $re_add(b981) $revert(b659) 'using platform::string_view;' | |
139 | + @ "namespace %platform_ex::XCB", | |
140 | + - $detail $impl "prefix 'platform::' before %string", | |
141 | + - $revert(b563) "header inclusion <atomic>' | |
142 | + ) | |
143 | + + $lib "header inclusion <cstdint>", | |
144 | + / $lib "header inclusion %YCommon" @ (%Mutex -> "%Platform", | |
145 | + %Timer -> ("%Platform", "<cstdint>")), | |
146 | + ( | |
147 | + + %Basic; | |
148 | + / ("inline namespace %basic_types" @ "namespace %platform", | |
149 | + 'using namespace platform::basic_types;' | |
150 | + @ "namespace %platform_ex") @ %Platform >> %Basic | |
151 | + $dep_to "simplified Platform.h", | |
152 | + / ("inline namespace %basic_utilities" @ "namespace %platform", | |
153 | + 'using namespace platform::basic_utilities;' | |
154 | + @ "namespace %platform_ex") @ %Container >> %Basic, | |
155 | + / $forced "header inclusion %Container" @ %JNI -> "%Basic", | |
156 | + / $revert(b894) "header inclusion \ | |
157 | + %YBase.YStandardEx.CStandardDefinition" @ %Platform | |
158 | + -> "%YBase.YDefiintion" $dep_from "simplified Platform.h" | |
159 | + ), | |
160 | + / $dev $lib "reordered macro definitions" @ %YModules | |
161 | + // As %Documentation::YCLib. | |
162 | + / %YContainer $= | |
163 | + ( | |
164 | + + $dep_from "header inclusion %Basic"; | |
165 | + / $re_add(b975) $dev $lib ^ "%pair" ~ "%std::pair" $effective | |
166 | + @ "alias templates %(map, multimap, unordered_map, \ | |
167 | + unordered_multimap, set, multiset, value_map, \ | |
168 | + value_multimap, linked_map, linked_multimap, \ | |
169 | + ordered_value_multimap, ordered_linked_map, \ | |
170 | + ordered_linked_multimap)" | |
171 | + ), | |
172 | + * "wrong architecture detection for %YF_Platform" | |
173 | + @ "platform %Linux" $since b559 | |
174 | + ), | |
175 | + / %YSLib $= | |
176 | + ( | |
177 | + / %Adaptor.YAdaptor $= | |
178 | + ( | |
179 | + / ('using ystdex::noncopyable;', 'using ystdex::nonmovable') | |
180 | + @ "namespace %YSLib" | |
181 | + >> $dep_from ("inline namespace %platform::basic_types" | |
182 | + @ %YCLib.Basic) $dep_to "lift basic bases", | |
183 | + // This is basically compatible due to the target \ | |
184 | + namespace introduced via 'using namespace' here. | |
185 | + / DLDI "string library aliases" | |
186 | + ), | |
187 | + / DLDI %Core $= | |
188 | + ( | |
189 | + / "local variable name" | |
190 | + @ "member function %ValueObject::Equals" @ %Core.YObject, | |
191 | + / "destructor %Application" @ %Core.YApplication | |
192 | + !^ 'YB_UNLIKELY', | |
193 | + ), | |
194 | + / %UI $= | |
195 | + ( | |
196 | + / DLDI %YUIContaienr $= | |
197 | + ( | |
198 | + + "header inclusions (%YBase.YStandardEx.Ref, <algorithm>)", | |
199 | + / "qualified 'YSLib::' before 'make_observer'", | |
200 | + / "qualified 'ystdex::' before 'bind1'" | |
201 | + ), | |
202 | + / $dev $lib %Loader $= | |
203 | + ( | |
204 | + / $detail "qualified 'YSLib::' before 'make_unique'" | |
205 | + $effective @ "function template %CreateUniqueWidget", | |
206 | + / "member function %WidgetLoader::TransformUILayout" $= | |
207 | + ( | |
208 | + / "qualified 'YSLib::' before 'AsNode'", | |
209 | + / "simplified" ^ 'auto' ~ 'ValueNode' | |
210 | + ), | |
211 | + / $detail $impl "cast to 'ZOrder'" @ "member \ | |
212 | + function %WidgetLoader::TransformUILayout" | |
213 | + // To eliminate Microsoft VC++ warning: C4244. | |
214 | + ) | |
215 | + ), | |
216 | + / %Service $= | |
217 | + ( | |
218 | + / %ImageProcessing $= | |
219 | + ( | |
220 | + + $re_add(b981) $dev $lib 'YB_ATTR_nodiscard' | |
221 | + @ "all definitions with %DefGetterMem", | |
222 | + + DLDI "header inclusions %YBase.YStandard.Cache", | |
223 | + / DLDI "qualified 'YSLib::' before 'make_shared'" | |
224 | + ), | |
225 | + / DLDI "function %FillCircle" @ %YDraw | |
226 | + !^ 'using namespace std;', | |
227 | + - DLDI 'using namespace ystdex;' @ %(YBlend, TextRenderer), | |
228 | + / %FileSystem $= | |
229 | + ( | |
230 | + / @ "namespace %IO" $= | |
231 | + ( | |
232 | + / DLDI "parameter name 'str'" @ "function template \ | |
233 | + %VerifyDirectoryPathTail" -> 'path', | |
234 | + // To be consistent with other API. | |
235 | + + "function template %LoadMappedModule" | |
236 | + ), | |
237 | + / @ "namespace %Deployment" $= | |
238 | + ( | |
239 | + + "function %CheckLocalFHSLayout with 2 parameter"; | |
240 | + + "class %RootPathBlock" ^ | |
241 | + ("%IO::EndsWithNonSeperator" @ %YAdaptor.Adaptor) | |
242 | + ) | |
243 | + ) | |
244 | + ) | |
245 | + ), | |
246 | + / %Helper $= | |
247 | + ( | |
248 | + / %ShellHelper ^ 'YB_NONNULL' $= | |
249 | + ( | |
250 | + / "minor space removal" @ "constructor %DebugTimer#1" | |
251 | + @ '!defined(NDEBUG)', | |
252 | + / DLDI "internal implementation" @ "functions %TranslateTime" | |
253 | + ^ 'YB_NONNULL' | |
254 | + ), | |
255 | + / %Initialization $= | |
256 | + ( | |
257 | + / "functions %(CheckLocalFHSLayout, GetLocalFHSRootPathOf)" $= | |
258 | + ( | |
259 | + / DLI "enabled allocator in construction of initial \ | |
260 | + %IO::Path object"; | |
261 | + >> "namespace %Deployment" @ %YSLib.Service.FileSystem, | |
262 | + ), | |
263 | + / DLI "prenvented redundant copy of the result from \ | |
264 | + configuration vector" @ "function %LoadConfiguration", | |
265 | + / DLDI "simplified function %LoadComponents" ^ $dep_from | |
266 | + ("%IO::LoadMappedModule" @ %YSLib.Service.FileSystem) | |
267 | + / DLDI "simplified function %FetchDefaultFontCache", | |
268 | + / DLI "simplified functions %(FetchLocalFHSRootPath, \ | |
269 | + LoadConfiguration, SaveConfiguration)" | |
270 | + ^ ("%Deployment::RootPathBlock" | |
271 | + @ %YSLib.Service.FileSystem), | |
272 | + / $revert_ex(b899) "function %(FetchLocalFHSRootPath, \ | |
273 | + FetchRootPathString)" -> "function %FetchRootPathCache" | |
274 | + ^ ("%Deployment::RootPathBlock" @ %YSLib.Service.FileSystem) | |
275 | + // These can be relplaced by %(GetSavedLocalFHSRootPath, \ | |
276 | + GetPathString) in %RootPathBlock. | |
277 | + ) | |
278 | + ), | |
279 | + / $lib %'YCLib_(DS)'.DSIO $= | |
280 | + ( | |
281 | + + $dev $detail $impl "header inclusion %YCLib.YCommon" | |
282 | + @ "implementation unit"; | |
283 | + / "header inclusion %YCommon" @ %'YCLib_(DS)'.DSIO | |
284 | + -> ("%Platform", "%Basic" @ 'YCL_DS') $dep_from %YCLib.Basic | |
285 | + ), | |
286 | + / DLI "simplified use of %(noncopyable, nonmovable)" | |
287 | + @ "namespaces %platform_ex" @ %(YCLib.XCB, 'YCLib_(DS)'.DSIO) | |
288 | + $dep_from ("lift basic bases"; ^ %YCLib.Basic) $= | |
289 | + ( | |
290 | + - "header inclusion %YBase.StandardEx.Base" $effecitve | |
291 | + // This is included in %YCLib.Basic. | |
292 | + - "prefix 'ystdex::'", | |
293 | + - "prefix 'YSLib::'" | |
294 | + ) | |
295 | + ), | |
296 | + / $re_add(b971) "updated copyright year" @ "label text" | |
297 | + @ "constructor %AboutPanel" @ %YReader.About, | |
298 | + / $re_ex(b900) "updated year" @ "%SUBTITLE2" @ "makefile" @ "platform %DS" | |
299 | + @ "project %YSTest" | |
300 | +), | |
301 | + | |
302 | +b981 | |
303 | +( | |
35 | 304 | / %Tools $= |
36 | 305 | ( |
37 | 306 | / "adjusted compiler options for projects not using custom makefile" |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2012-2023 FrankHB. | |
2 | + © 2012-2024 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file YCLib.txt |
12 | 12 | \ingroup Documentation |
13 | 13 | \brief YCLib 说明。 |
14 | -\version r605 | |
14 | +\version r622 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since build 651 |
17 | 17 | \par 创建时间: |
18 | 18 | 2015-11-19 09:05:02 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2023-07-16 00:12 +0800 | |
20 | + 2024-02-26 00:56 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -312,10 +312,20 @@ | ||
312 | 312 | 使用 POSIX.1 文件系统 API 的实现要求最低版本 POSIX.1-2008 。 |
313 | 313 | |
314 | 314 | @4.2.1 平台约定: |
315 | -DS 平台可沿用部分 POSIX 限制。 | |
316 | -注意 POSIX 系统限制可能不在编译时确定;非特定平台不应假定。 | |
315 | +没有实现的依赖具体平台的 API 的使用可在运行时无条件引发错误,如抛出异常。 | |
316 | + | |
317 | +@4.2.1.1 系统限制: | |
318 | +POSIX 系统限制可能不在编译时确定;非特定平台不应假定。 | |
317 | 319 | 仅在 platform::FetchLimit 的实现中使用存在对应运行时配置的宏。 |
318 | 320 | |
321 | +@4.2.1.2 DS 平台: | |
322 | +DS 平台不符合 POSIX 标准,但因使用 newlib 作为系统库,可使用部分 POSIX.1 API 并沿用部分 POSIX 限制。 | |
323 | +DS 不支持 POSIX.2 。 | |
324 | +**注释** 关于 newlib 提供的兼容接口(系统调用接口),参见 https://sourceware.org/newlib/libc.html#Stubs ;这不表示 POSIX.2 函数( https://sourceware.org/newlib/libc.html#Posix )可用。 | |
325 | +DS 平台下类 POSIX 的 API 部分语义和 POSIX 不同: | |
326 | + 查询文件元数据时,::stat::st_ctime 表示文件创建时间(creation time) 而非(内容或元数据的)更改时间(change time) 。 | |
327 | + **原理** DS 只支持 FAT 文件系统,更改时间同修改时间,不需要占用其它元数据接口提供 FAT 创建时间。DSIO(@7.1.1) 和以往的 libfat 都使用 st_ctime 保存创建时间而非更改时间。 | |
328 | + | |
319 | 329 | @4.2.1 标识符: |
320 | 330 | POSIX 函数视为全局命名空间成员。 |
321 | 331 | 在 YCLib::NativeAPI(@5.2) 中 #undef 对应的宏以使函数可被直接(不需要在标识符外以括号保护)使用。 |
@@ -335,11 +345,15 @@ | ||
335 | 345 | |
336 | 346 | @5.2 NativeAPI : |
337 | 347 | 提供平台相关的 API 实现,也可在全局命名空间补充特定平台的兼容接口声明或定义的修复。 |
348 | +NativeAPI 按 Platform(@5.1) 的定义提供平台特定的功能特性 API 。部分 API 仅供内部实现使用。 | |
338 | 349 | |
339 | 350 | @5.3 适配模块: |
340 | 351 | 类似 YSLib::Adaptor([Documentation::YSLib @@2.1]) ,在 YCLib 的顶级平台命名空间([Documentation::YFramework @@2.3.4]) 引入声明。 |
341 | 352 | |
342 | -@5.3.1 Reference 指针和引用访问操作模块: | |
353 | +@5.3.1 Basic 基本接口: | |
354 | +在命名空间 platform 中提供命名空间 basic_types 和 basic_utilities(@1.3.1.1) 。 | |
355 | + | |
356 | +@5.3.2 Reference 指针和引用访问操作模块: | |
343 | 357 | 在这个模块中配置和声明智能指针等引用对象类型。 |
344 | 358 | 之前被作为 YSLib::Adaptor::YReference ,在 YSLib 命名空间引入外部名称。 |
345 | 359 | 可包装 Loki 或 std::tr1 指针智能等实现。 |
@@ -351,13 +365,13 @@ | ||
351 | 365 | 部分名称从 YBase([Documentation::YBase]) 的命名空间 ystdex 中引入。 |
352 | 366 | 引入的命名空间来源通常属于实现细节,不应被依赖。 |
353 | 367 | |
354 | -@5.3.2 容器、拟容器和适配器 Container : | |
368 | +@5.3.3 容器、拟容器和适配器 Container : | |
355 | 369 | 包含标准库容器相关的头,并在顶级平台命名空间([Documentation::YFramework @@2.3.4]) 引入相关名称。 |
356 | 370 | 之前被作为 YSLib::Adaptor::YContainer ,在 YSLib 命名空间引入外部名称。 |
357 | 371 | 包含 CHRLib([Documentation::CHRLib]) 的 CHRDefinition 。 |
358 | 372 | build 593 起从 YSLib::Adaptor 迁移至 YCLib ,在 platform 命名空间引入外部名称。 |
359 | 373 | |
360 | -@5.3.3 互斥量 Mutex : | |
374 | +@5.3.4 互斥量 Mutex : | |
361 | 375 | 基于 YBase 的 YStandardEx::PseudoMutex([Documentation::YBase @@2.5.8.16]) 为多线程和单线程环境提供统一的同步接口。 |
362 | 376 | 在命名空间 platform 中提供 Concurrency 和 Threading 两个子命名空间,再在其中引入外部名称。 |
363 | 377 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - © 2009-2023 FrankHB. | |
2 | + © 2009-2024 FrankHB. | |
3 | 3 | |
4 | 4 | This file is part of the YSLib project, and may only be used, |
5 | 5 | modified, and distributed under the terms of the YSLib project |
@@ -11,13 +11,13 @@ | ||
11 | 11 | /*! \file YFramework.txt |
12 | 12 | \ingroup Documentation |
13 | 13 | \brief YFramework 设计和实现说明。 |
14 | -\version r1657 | |
14 | +\version r1668 | |
15 | 15 | \author FrankHB <frankhb1989@gmail.com> |
16 | 16 | \since 早于 build 132 |
17 | 17 | \par 创建时间: |
18 | 18 | 2009-12-02 05:14:30 +0800 |
19 | 19 | \par 修改时间: |
20 | - 2023-03-06 12:57 +0800 | |
20 | + 2024-02-25 22:10 +0800 | |
21 | 21 | \par 文本编码: |
22 | 22 | UTF-8 |
23 | 23 | \par 模块名称: |
@@ -96,16 +96,13 @@ | ||
96 | 96 | 实现可假定程序不存在使用 POSIX fork 引起进程内环境变量的并发数据竞争。 |
97 | 97 | |
98 | 98 | @1.4.1.5 外部环境: |
99 | -作为符合和其它软件规范约定的一部分,除非应用另行指定,以下环境变量被支持: | |
100 | -NO_COLOR :若这个环境变量被设置为非空值,宿主实现环境忽略终端支持的彩色和其它视觉效果格式(如下划线)特性。 | |
99 | +作为符合和其它软件规范约定的一部分,除非应用另行指定,在 https://frankhb.github.io/YSLib-book/Run.zh-CN.html#%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F 中指定的环境变量被支持。 | |
101 | 100 | 除标准库和系统配置外,YFramework 可使用以下环境变量改变运行时行为: |
102 | 101 | YF_DEBUG_OUTPUT :若这个环境变量的值设置为 1 ,使用调试日志(@5.3) 。 |
103 | 102 | 当前仅在 Windows 平台使用。 |
104 | 103 | YF_Use_tput :若这个环境变量被设置为非空值,宿主实现环境需要终端特性时,使用 tput 命令而不是内建的终端控制字符序列发送控制命令。 |
105 | 104 | 当前仅在非 Windows 平台使用。 |
106 | 105 | 除非另行指定,程序可假定以上环境变量不变,即仅在程序初始化时检查一次。 |
107 | -**注释** | |
108 | -NO_COLOR 符合 https://no-color.org/ 的约定。 | |
109 | 106 | |
110 | 107 | @1.4.2 资源分类: |
111 | 108 | 基本内容参见 [Documentation::CommonRules @@2.3.2.2] 。 |
@@ -409,9 +406,10 @@ | ||
409 | 406 | |
410 | 407 | @2.1.3.2 语言扩展: |
411 | 408 | 可选使用源代码语义兼容 GCC 的 128 位整数,作为替代的优化实现。 |
412 | -在 [Documentation::YBase @@2.1.1.2] 的基础上,实现允许以下可选的语言扩展作为替代的优化实现: | |
409 | +在 [Documentation::YBase @@2.1.1.2] 的基础上,实现允许以下可选的语言扩展作为增强或替代的优化实现: | |
413 | 410 | __builtin_add_overflow |
414 | 411 | __builtin_mul_overflow |
412 | +__builtin_object_size | |
415 | 413 | __builtin_sub_overflow |
416 | 414 | _umul128 |
417 | 415 | 在 [Documentation::YBase @@2.1.1.2] 的基础上,实现允许以下可选的语言扩展作为提供可选增强的实现特性: |
@@ -469,7 +467,9 @@ | ||
469 | 467 | |
470 | 468 | @2.1.6 预处理附加规则: |
471 | 469 | 对公开的 YFramework 头文件包含依赖关系,在 #include 指令中使用 YFM_* 宏而不是文件名(因此仅修改头文件名时不变更版本([Documentation::ProjectRules @@2.2.6]));之前需要包含对应的 "YModules.h" (若在当前头文件中存在则使用直接相对路径,否则使用相对 YFramework/include 的路径)。 |
472 | -指定限定平台集合(@2.1.4) 的宏(如 YF_Hosted )不得被用于出现在 YSLib 中用于条件编译(关于依赖性限制,参见 @2.2.5)。 | |
470 | +指定限定平台集合(@2.1.4) 的宏(如 YF_Hosted )不得被用于 YSLib 中用于条件包含。 | |
471 | +YF_Hosted 以外的指定限定平台集合(@2.1.4) 的宏不得被用于 NPL 中用于条件包含。 | |
472 | +关于依赖性限制,参见 @2.2.5 。 | |
473 | 473 | |
474 | 474 | @2.2 文件依赖性: |
475 | 475 | YSLib 和 Helper(@2.8) 文件中,文件名以 y 或 Y 起始且非限定模块名以 Y 起始的文件为必要文件,其它为非必要文件。 |
@@ -582,7 +582,7 @@ | ||
582 | 582 | @2.4.2 对象引用和所有权管理: |
583 | 583 | 基本概念参见 [Documentation::CommonRules @@2.3.4] 。 |
584 | 584 | 实现方式应符合 [CommonRules::LanguageConvention @@5.2.9.3.1] 和 [Documentation::LanguageConvention @@6.9.2] 。 |
585 | -以下 API 中的非限定名称在 YFramework 代码对应的命名空间中可用,可能由 YCLib.Reference([Documentation::YCLib @@5.3.1]) 从不同命名空间中引入。 | |
585 | +以下 API 中的非限定名称在 YFramework 代码对应的命名空间中可用,可能由 YCLib.Reference([Documentation::YCLib @@5.3.2]) 从不同命名空间中引入。 | |
586 | 586 | 注意基于非透明引用计数实现的非侵入式智能指针(如 boost::shared_ptr/std::tr1::shared_ptr 以及 C++11 的 std::shared_ptr )具有以下固有的缺点: |
587 | 587 | 无法修改引用计数并直接转移所有权,资源实例的生存期依赖至少一个具体智能指针对象的生存期; |
588 | 588 | 资源实例对智能指针对象的上述依赖性导致智能指针类型入侵用户程序接口; |