Merge branch 'upstream' into tizen
[platform/upstream/cryptsetup.git] / tests / fuzz / json_proto_converter.h
1 // Copyright 2020 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 ////////////////////////////////////////////////////////////////////////////////
16
17 #ifndef JSON_PROTO_CONVERTER_H_
18 #define JSON_PROTO_CONVERTER_H_
19
20 #include <sstream>
21 #include <string>
22
23 #include "LUKS2_plain_JSON.pb.h"
24
25 namespace json_proto {
26
27 class JsonProtoConverter {
28  public:
29   std::string Convert(const json_proto::JsonObject&);
30   std::string Convert(const json_proto::ArrayValue&);
31
32  private:
33   std::stringstream data_;
34
35   void AppendArray(const json_proto::ArrayValue&);
36   void AppendNumber(const json_proto::NumberValue&);
37   void AppendObject(const json_proto::JsonObject&);
38   void AppendValue(const json_proto::JsonValue&);
39 };
40
41 }  // namespace json_proto
42
43 #endif  // TESTING_LIBFUZZER_PROTO_JSON_PROTO_CONVERTER_H_