Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Patch.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_DataExchange_JSON_PATCH_h_
5#define _Stroika_Foundation_DataExchange_JSON_PATCH_h_ 1
6
7#include "Stroika/Frameworks/StroikaPreComp.h"
8
10#include "Stroika/Foundation/Containers/Sequence.h"
11#include "Stroika/Foundation/DataExchange/JSON/Pointer.h"
12#include "Stroika/Foundation/DataExchange/ObjectVariantMapper.h"
13
14/**
15 */
16namespace Stroika::Foundation::DataExchange::JSON::Patch {
17
18 using namespace Stroika::Foundation;
19
22
23 // SEE https://jsonpatch.com/
24 // SEE https://www.rfc-editor.org/rfc/rfc6902
25
26 /**
27 * @todo more OperationType values
28 */
29 enum class OperationType {
30 eAdd,
31 eRemove,
32
33 Stroika_Define_Enum_Bounds (eAdd, eRemove)
34 };
35
36 /**
37 */
38 struct OperationItemType {
39 OperationType op;
40 PointerType path;
41 optional<VariantValue> value;
42
43 /**
44 * Apply the operation to the argument VariantValue object, and return the mutated result.
45 *
46 * \note - @todo - as of Stroika v3.0d6 - QUITE INCOMPLETE IMPLEMENTATION - but alot of the infrastucture there to complete it (jsonpointer search/update - but thats not 100%).
47 */
48 nonvirtual VariantValue Apply (const VariantValue& v) const;
49
50 /**
51 * @see Characters::ToString ();
52 */
53 nonvirtual String ToString () const;
54
55 static const DataExchange::ObjectVariantMapper kMapper;
56 };
57
58 /**
59 */
60 struct OperationItemsType : Containers::Sequence<OperationItemType> {
61
62 /**
63 * Apply each operation in sequence to the argument VariantValue object, and return the mutated result.
64 */
65 nonvirtual VariantValue Apply (const VariantValue& v) const;
66
67 static const DataExchange::ObjectVariantMapper kMapper;
68 };
69
70}
71
72/*
73 ********************************************************************************
74 ***************************** Implementation Details ***************************
75 ********************************************************************************
76 */
77#include "Patch.inl"
78
79#endif /*_Stroika_Foundation_DataExchange_JSON_PATCH_h_*/
#define Stroika_Define_Enum_Bounds(FIRST_ITEM, LAST_ITEM)
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
A generalization of a vector: a container whose elements are keyed by the natural numbers.
Definition Sequence.h:187
ObjectVariantMapper can be used to map C++ types to and from variant-union types, which can be transp...
Simple variant-value (case variant union) object, with (variant) basic types analogous to a value in ...
nonvirtual void Apply(const function< void(ArgByValueType< T > item)> &doToElement, Execution::SequencePolicy seq=Execution::SequencePolicy::eDEFAULT) const
Run the argument function (or lambda) on each element of the container.
STRING_TYPE ToString(FLOAT_TYPE f, const ToStringOptions &options={})