-
Notifications
You must be signed in to change notification settings - Fork 0
/
json_patch_writer.h
37 lines (33 loc) · 1.36 KB
/
json_patch_writer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once
#include <sstream>
#include "nlohmann/json.hpp"
#include "global_settings.h"
#include "parse_settings.h"
enum patchOperation {
addValue,
replaceValue,
removeValue,
copyValue,
moveValue,
testValue,
testInverse
};
class JsonPatchWriter {
private:
PatchStyleSettings baselinePatchStyle;
bool useInverseTestOps;
bool useOperationSets;
int indentModifier;
int currentOps;
int currentOpSets;
bool writeOperationSet(std::stringstream & patchText, const PointerSettings & pointerSettings, const nlohmann::json & sourceJson, const nlohmann::json & intermediaryJson);
bool writeRecursiveOperationSet(std::stringstream & patchText, const PointerSettings & pointerSettings, const nlohmann::json & sourceJson, const nlohmann::json & intermediaryJson);
void writeOperation(std::stringstream & patchText, std::string path, std::string value, patchOperation operation);
void writeOperationSetOpener(std::stringstream & patchText);
void writeOperationSetCloser(std::stringstream & patchText);
void writeIndent(std::stringstream & patchText);
void writeColon(std::stringstream & patchText);
public:
JsonPatchWriter(MasterSettings masterSettings);
int writePatchFile(std::stringstream & patchText, FileSettings & fileSettings, const nlohmann::json & sourceJson, const nlohmann::json & intermediaryJson);
};