• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 HILOG_MSG_WRAPPER_H
17 #define HILOG_MSG_WRAPPER_H
18 
19 #include <cstring>
20 #include <iostream>
21 #include <securec.h>
22 
23 #include <hilog/log.h>
24 #include "hilogtool_msg.h"
25 
26 namespace OHOS {
27 namespace HiviewDFX {
28 
29 class HilogMsgWrapper {
30 public:
HilogMsgWrapper(const std::vector<char> & _msgBuffer)31     explicit HilogMsgWrapper(const std::vector<char> & _msgBuffer) : msgBuffer(_msgBuffer)
32     {}
HilogMsgWrapper(std::vector<char> && _msgBuffer)33     explicit HilogMsgWrapper(std::vector<char> && _msgBuffer)
34     {
35         std::swap(msgBuffer, _msgBuffer);
36     }
GetHilogMsg()37     HilogMsg& GetHilogMsg()
38     {
39         return *reinterpret_cast<HilogMsg*>(msgBuffer.data());
40     }
41 
GetRawData()42     const std::vector<char> & GetRawData() const
43     {
44         return msgBuffer;
45     }
46 
47 private:
48     std::vector<char> msgBuffer;
49 };
50 } // namespace HiviewDFX
51 } // namespace OHOS
52 #endif /* HILOG_MSG_WRAPPER_H */
53