File tree Expand file tree Collapse file tree 2 files changed +36
-5
lines changed
universal/src/formats/yaml Expand file tree Collapse file tree 2 files changed +36
-5
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ def requirements(self):
118118 self .requires ('libev/[^4.33]' )
119119 self .requires ('openssl/[>=1.1 <4]' )
120120 self .requires ('rapidjson/[>=cci.20230929 <cci.20230930]' , transitive_headers = True )
121- self .requires ('yaml-cpp/[^ 0.8.0]' )
121+ self .requires ('yaml-cpp/[>= 0.8.0 <=0.9 .0]' )
122122 self .requires ('zlib/[^1.3]' )
123123 self .requires ('zstd/[^1.5]' )
124124 self .requires ('icu/[>=74.1 <77]' , force = True )
Original file line number Diff line number Diff line change 1111#include " exttypes.hpp"
1212#include " string_view_support.hpp"
1313
14- USERVER_NAMESPACE_BEGIN
15-
16- namespace formats ::yaml {
17-
1814namespace {
1915
2016// Helper structure for YAML conversions. YAML has built in conversion logic and
@@ -32,6 +28,41 @@ struct IsConvertibleChecker {
3228 }
3329};
3430
31+ } // anonymous namespace
32+
33+ namespace YAML {
34+
35+ // Reverting harm done by https://github.com/jbeder/yaml-cpp/commit/96f5c887f373ac483844c51cfc9a3621002314f0
36+ // to detect if the conversion is successful without throwing an exception
37+ template <typename T>
38+ requires std::integral<T> || std::floating_point<T>
39+ struct as_if <T, IsConvertibleChecker<T> > {
40+ explicit as_if (const Node& node_in)
41+ : node(node_in)
42+ {}
43+ const Node& node;
44+
45+ T operator ()(const IsConvertibleChecker<T>& fallback) const {
46+ if (!node.m_pNode ) {
47+ return fallback;
48+ }
49+
50+ T t;
51+ if (convert<T>::decode (node, t)) {
52+ return t;
53+ }
54+ return fallback;
55+ }
56+ };
57+
58+ } // namespace YAML
59+
60+ USERVER_NAMESPACE_BEGIN
61+
62+ namespace formats ::yaml {
63+
64+ namespace {
65+
3566auto MakeMissingNode () { return YAML::Node{}[0 ]; }
3667
3768// yaml-cpp allows to parse quoted and typed strings into bool and numeric
You can’t perform that action at this time.
0 commit comments