Microsoft Information Protection SDK - C++ 1.17
API Reference Documentation for C++
Loading...
Searching...
No Matches
json_value.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (c) Microsoft Corporation.
4 * All rights reserved.
5 *
6 * This code is licensed under the MIT License.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files(the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions :
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
31#ifndef API_MIP_JSON_VALUE_H_
32#define API_MIP_JSON_VALUE_H_
33
34#include <memory>
35#include <string>
36#include <vector>
37
38#include "mip/mip_namespace.h"
39
40MIP_NAMESPACE_BEGIN
41
42class JsonValue {
43public:
49 virtual bool IsString() const = 0;
55 virtual bool IsArray() const = 0;
61 virtual bool IsObject() const = 0;
67 virtual bool HasMember(const std::string& key) const = 0;
71 virtual void PushBack(const std::shared_ptr<JsonValue>& jsonValue) = 0;
76 virtual void PushBack(const std::string& member) = 0;
80 virtual void AddMember(const std::string& key, const std::shared_ptr<JsonValue>& jsonValue) = 0;
81 /*
82 * @brief Add a string member to an Object with the specified key and value.
83 * @param key The key of the member to add.
84 * @param member The value of the member to add.
85 */
86 virtual void AddMember(const std::string& key, const std::string& member) = 0;
92 virtual void AddMember(const std::string& key, bool member) = 0;
98 virtual void AddMember(const std::string& key, int member) = 0;
104 virtual void AddMember(const std::string& key, unsigned int member) = 0;
110 virtual std::shared_ptr<JsonValue> GetMember(const std::string& key) const = 0;
115 virtual std::shared_ptr<JsonValue> GetMember(unsigned int index) const = 0;
120 virtual size_t Size() const = 0;
126 virtual std::vector<std::string> GetStringArray() const = 0;
133 virtual std::vector<std::pair<std::string, std::string>> GetStringObjectMembers() const = 0;
138 virtual std::string GetString() const = 0;
143 virtual bool IsInt() const = 0;
148 virtual int GetInt() const = 0;
153 virtual bool IsBool() const = 0;
158 virtual bool IsUint() const = 0;
163 virtual unsigned int GetUint() const = 0;
168 virtual bool IsNumber() const = 0;
173 virtual double GetDouble() const = 0;
178 virtual bool GetBool() const = 0;
183 virtual std::string SerializeToString() const = 0;
184
186 virtual ~JsonValue() {};
188};
189
190MIP_NAMESPACE_END
191
192#endif // API_MIP_JSON_VALUE_H_
Definition json_value.h:42
virtual std::vector< std::string > GetStringArray() const =0
return value array as strings, skip non string elements.
virtual int GetInt() const =0
If the current value is an int, return it.
virtual void AddMember(const std::string &key, unsigned int member)=0
Add an unsigned integer member to an Object with the specified key and value.
virtual std::string SerializeToString() const =0
Serialize the value and all children as a string.
virtual void AddMember(const std::string &key, const std::shared_ptr< JsonValue > &jsonValue)=0
Add a value member to an Object. The object should not be modified after being added.
virtual double GetDouble() const =0
If the current value is a double, return it.
virtual bool IsObject() const =0
check if value is a json object.
virtual bool IsUint() const =0
Return true if the current value is an unsigned int.
virtual void PushBack(const std::string &member)=0
Add a string member to an Array with the specified value.
virtual bool IsInt() const =0
Returns true if the current value is an int.
virtual void PushBack(const std::shared_ptr< JsonValue > &jsonValue)=0
Add a value member to an Array. The object should not be modified after being added.
virtual void AddMember(const std::string &key, int member)=0
Add a signed integer member to an Object with the specified key and value.
virtual bool IsArray() const =0
check if value is a json array.
virtual bool GetBool() const =0
If the current value is a bool, return it.
virtual void AddMember(const std::string &key, bool member)=0
Add a boolean member to an Object with the specified key and value.
virtual size_t Size() const =0
return number of child elements.
virtual bool IsBool() const =0
Return true if the current value is a bool.
virtual unsigned int GetUint() const =0
If the current value is a uint, return it.
virtual bool HasMember(const std::string &key) const =0
return true if object has a child with the specified key.
virtual bool IsNumber() const =0
Return true if the current value is a number of any type.
virtual bool IsString() const =0
check if value is a string.
virtual std::shared_ptr< JsonValue > GetMember(unsigned int index) const =0
return child value at specified index if this is an Array.
virtual std::vector< std::pair< std::string, std::string > > GetStringObjectMembers() const =0
Return all string members of this object and their keys, skip non string elements....
virtual std::shared_ptr< JsonValue > GetMember(const std::string &key) const =0
return child value with the specified key if this is an Object.
virtual void AddMember(const std::string &key, const std::string &member)=0
virtual std::string GetString() const =0
If the current value is a string, return it.
MIP namespace macros.