openthread-br  0.3.0-72c0388
json.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020, The OpenThread Authors.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * 3. Neither the name of the copyright holder nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
34 #ifndef OTBR_REST_JSON_HPP_
35 #define OTBR_REST_JSON_HPP_
36 
37 #include "openthread/link.h"
38 #include "openthread/thread_ftd.h"
39 
40 #include "rest/types.hpp"
41 #include "utils/hex.hpp"
42 
43 namespace otbr {
44 namespace rest {
45 
51 namespace Json {
52 
61 std::string Number2JsonString(const uint32_t &aNumber);
62 
71 std::string Bytes2HexJsonString(const uint8_t *aBytes, uint8_t aLength);
72 
81 std::string CString2JsonString(const char *aCString);
82 
91 std::string String2JsonString(const std::string &aString);
92 
101 std::string Node2JsonString(const NodeInfo &aNode);
102 
111 std::string Diag2JsonString(const std::vector<std::vector<otNetworkDiagTlv>> &aDiagSet);
112 
121 std::string IpAddr2JsonString(const otIp6Address &aAddress);
122 
131 std::string Mode2JsonString(const otLinkModeConfig &aMode);
132 
141 std::string Connectivity2JsonString(const otNetworkDiagConnectivity &aConnectivity);
142 
151 std::string Route2JsonString(const otNetworkDiagRoute &aRoute);
152 
161 std::string RouteData2JsonString(const otNetworkDiagRouteData &aRouteData);
162 
171 std::string LeaderData2JsonString(const otLeaderData &aLeaderData);
172 
181 std::string MacCounters2JsonString(const otNetworkDiagMacCounters &aMacCounters);
182 
191 std::string ChildTableEntry2JsonString(const otNetworkDiagChildEntry &aChildEntry);
192 
202 std::string Error2JsonString(HttpStatusCode aErrorCode, std::string aErrorMessage);
203 
204 }; // namespace Json
205 
206 } // namespace rest
207 } // namespace otbr
208 
209 #endif // OTBR_REST_JSON_HPP_
otbr::rest::Json::RouteData2JsonString
std::string RouteData2JsonString(const otNetworkDiagRouteData &aRouteData)
Definition: json.cpp:405
otbr::rest::Json::Connectivity2JsonString
std::string Connectivity2JsonString(const otNetworkDiagConnectivity &aConnectivity)
Definition: json.cpp:395
otbr::rest::Json::LeaderData2JsonString
std::string LeaderData2JsonString(const otLeaderData &aLeaderData)
Definition: json.cpp:425
otbr::rest::Json::Bytes2HexJsonString
std::string Bytes2HexJsonString(const uint8_t *aBytes, uint8_t aLength)
Definition: json.cpp:365
otbr::rest::Json::Diag2JsonString
std::string Diag2JsonString(const std::vector< std::vector< otNetworkDiagTlv >> &aDiagSet)
Definition: json.cpp:238
otbr::rest::Json::Mode2JsonString
std::string Mode2JsonString(const otLinkModeConfig &aMode)
Definition: json.cpp:385
hex.hpp
otbr::rest::Json::String2JsonString
std::string String2JsonString(const std::string &aString)
Definition: json.cpp:52
otbr::rest::Json::Number2JsonString
std::string Number2JsonString(const uint32_t &aNumber)
Definition: json.cpp:375
types.hpp
otbr::rest::Json::CString2JsonString
std::string CString2JsonString(const char *aCString)
Definition: json.cpp:455
otbr::rest::Json::Error2JsonString
std::string Error2JsonString(HttpStatusCode aErrorCode, std::string aErrorMessage)
Definition: json.cpp:465
otbr::rest::Json::MacCounters2JsonString
std::string MacCounters2JsonString(const otNetworkDiagMacCounters &aMacCounters)
Definition: json.cpp:435
otbr::rest::Json::IpAddr2JsonString
std::string IpAddr2JsonString(const otIp6Address &aAddress)
Definition: json.cpp:207
otbr::rest::Json::ChildTableEntry2JsonString
std::string ChildTableEntry2JsonString(const otNetworkDiagChildEntry &aChildEntry)
Definition: json.cpp:445
otbr::rest::Json::Route2JsonString
std::string Route2JsonString(const otNetworkDiagRoute &aRoute)
Definition: json.cpp:415
otbr::rest::Json::Node2JsonString
std::string Node2JsonString(const NodeInfo &aNode)
Definition: json.cpp:218