Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Pointer.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4
6
8
9 /*
10 ********************************************************************************
11 ******************************** JSON::PointerType *****************************
12 ********************************************************************************
13 */
14 template <Characters::IConvertibleToString STRINGISH_TYPE>
15 inline PointerType::PointerType (STRINGISH_TYPE&& s)
16 : PointerType{static_cast<const String&> (String{s})}
17 {
18 }
19 template <Common::IAnyOf<String> T>
20 inline T PointerType::As () const
21 {
22 if constexpr (same_as<T, String>) {
23 Characters::StringBuilder sb;
24 fComponents_.Apply ([&] (const String& s) { sb << "/"sv << s.ReplaceAll ("~"sv, "~0"sv).ReplaceAll ("/"sv, "~1"sv); });
25 return sb;
26 }
27 }
28 inline optional<VariantValue> PointerType::Apply (const VariantValue& v) const
29 {
30 return this->ApplyWithContext (v, nullptr);
31 }
32 inline auto PointerType::ApplyWithContext (const VariantValue& v) const -> optional<tuple<Context, VariantValue>>
33 {
34 Context c;
35 if (auto o = this->ApplyWithContext (v, &c)) {
36 return make_tuple (c, *o);
37 }
38 return nullopt;
39 }
40 inline const DataExchange::ObjectVariantMapper PointerType::kMapper = [] () {
42 mapper.Add<PointerType> ([] (const ObjectVariantMapper&, const PointerType* obj) -> VariantValue { return obj->As<String> (); },
43 [] (const ObjectVariantMapper&, const VariantValue& d, PointerType* intoObj) -> void {
44 *intoObj = PointerType{d.As<String> ()};
45 });
46 return mapper;
47 }();
48
49}
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
ObjectVariantMapper can be used to map C++ types to and from variant-union types, which can be transp...
nonvirtual void Add(const TypeMappingDetails &s)
Simple variant-value (case variant union) object, with (variant) basic types analogous to a value in ...