1 /*
2 * Copyright (c) 2023 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 TEST_CONVERTXML_H
17 #define TEST_CONVERTXML_H
18
19 #include "../js_convertxml.h"
20
21 namespace OHOS::Xml {
22 class CxmlTest {
23 public:
24 CxmlTest() = default;
25 ~CxmlTest() = default;
26 static std::string Trim(std::string strXmltrim);
27 static std::string GetNodeType(const xmlElementType enumType);
28 static void GetPrevNodeList(napi_env env, xmlNodePtr curNode);
29 static void SetXmlElementType(napi_env env, xmlNodePtr curNode, const napi_value &elementsObject, bool &bFlag);
30 static void SetNodeInfo(napi_env env, xmlNodePtr curNode, const napi_value &elementsObject);
31 static void DealSpaces(napi_env env, const napi_value napiObj);
32 static void SetDefaultKey(size_t i, const std::string strRecv);
33 static void DealSingleLine(napi_env env, std::string &strXml, const napi_value &object);
34 static void DealComplex(napi_env env, std::string &strXml, const napi_value &object);
35 static void Replace(std::string &str, const std::string src, const std::string dst);
36 static void DealCDataInfo(bool bCData, xmlNodePtr &curNode);
37 };
38
Trim(std::string strXmltrim)39 std::string CxmlTest::Trim(std::string strXmltrim)
40 {
41 ConvertXml convert;
42 return convert.Trim(strXmltrim);
43 }
44
GetNodeType(const xmlElementType enumType)45 std::string CxmlTest::GetNodeType(const xmlElementType enumType)
46 {
47 ConvertXml convert;
48 return convert.GetNodeType(enumType);
49 }
50
GetPrevNodeList(napi_env env,xmlNodePtr curNode)51 void CxmlTest::GetPrevNodeList(napi_env env, xmlNodePtr curNode)
52 {
53 ConvertXml convert;
54 convert.GetPrevNodeList(env, curNode);
55 }
56
SetXmlElementType(napi_env env,xmlNodePtr curNode,const napi_value & elementsObject,bool & bFlag)57 void CxmlTest::SetXmlElementType(napi_env env, xmlNodePtr curNode, const napi_value &elementsObject, bool &bFlag)
58 {
59 ConvertXml convert;
60 convert.SetXmlElementType(env, curNode, elementsObject, bFlag);
61 }
62
SetNodeInfo(napi_env env,xmlNodePtr curNode,const napi_value & elementsObject)63 void CxmlTest::SetNodeInfo(napi_env env, xmlNodePtr curNode, const napi_value &elementsObject)
64 {
65 ConvertXml convert;
66 convert.SetNodeInfo(env, curNode, elementsObject);
67 }
68
DealSpaces(napi_env env,const napi_value napiObj)69 void CxmlTest::DealSpaces(napi_env env, const napi_value napiObj)
70 {
71 ConvertXml convert;
72 convert.DealSpaces(env, napiObj);
73 }
74
SetDefaultKey(size_t i,const std::string strRecv)75 void CxmlTest::SetDefaultKey(size_t i, const std::string strRecv)
76 {
77 ConvertXml convert;
78 convert.SetDefaultKey(i, strRecv);
79 }
80
DealSingleLine(napi_env env,std::string & strXml,const napi_value & object)81 void CxmlTest::DealSingleLine(napi_env env, std::string &strXml, const napi_value &object)
82 {
83 ConvertXml convert;
84 convert.DealSingleLine(env, strXml, object);
85 }
86
DealComplex(napi_env env,std::string & strXml,const napi_value & object)87 void CxmlTest::DealComplex(napi_env env, std::string &strXml, const napi_value &object)
88 {
89 ConvertXml convert;
90 convert.DealComplex(env, strXml, object);
91 }
92
Replace(std::string & str,const std::string src,const std::string dst)93 void CxmlTest::Replace(std::string &str, const std::string src, const std::string dst)
94 {
95 ConvertXml convert;
96 convert.Replace(str, src, dst);
97 }
98
DealCDataInfo(bool bCData,xmlNodePtr & curNode)99 void CxmlTest::DealCDataInfo(bool bCData, xmlNodePtr &curNode)
100 {
101 ConvertXml convert;
102 convert.DealCDataInfo(bCData, curNode);
103 }
104 }
105 #endif // TEST_CONVERTXML_H
106