• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
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 #ifndef HIVIEW_PLUGINS_USAGE_EVENT_REPORT_SREVICE_EVENT_CACHER_H
17 #define HIVIEW_PLUGINS_USAGE_EVENT_REPORT_SREVICE_EVENT_CACHER_H
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 #include "logger_event.h"
24 #include "json/json.h"
25 
26 namespace OHOS {
27 namespace HiviewDFX {
28 class JsonParser {
29 public:
30     static bool ParsePluginStatsEvent(std::shared_ptr<LoggerEvent>& event, const std::string& jsonStr);
31     static bool ParseSysUsageEvent(std::shared_ptr<LoggerEvent>& event, const std::string& jsonStr);
32 
33     static bool ParseJsonString(Json::Value& root, const std::string& jsonStr);
34     static bool CheckJsonValue(const Json::Value& value, const std::vector<std::string>& fields);
35     static uint32_t ParseUInt32(const Json::Value& value);
36     static uint64_t ParseUInt64(const Json::Value& value);
37     static std::string ParseString(const Json::Value& value);
38     static void ParseUInt32Vec(const Json::Value& value, std::vector<uint32_t>& vec);
39     static void ParseStringVec(const Json::Value& value, std::vector<std::string>& vec);
40 };
41 } // namespace HiviewDFX
42 } // namespace OHOS
43 #endif // HIVIEW_PLUGINS_USAGE_EVENT_REPORT_SREVICE_EVENT_CACHER_H
44