Line  | Count  | Source  | 
1  |  | /*  | 
2  |  |  * Copyright (C) 2019 Google Inc.  | 
3  |  |  *  | 
4  |  |  * Licensed under the Apache License, Version 2.0 (the "License");  | 
5  |  |  * you may not use this file except in compliance with the License.  | 
6  |  |  * You may obtain a copy of the License at  | 
7  |  |  *  | 
8  |  |  * http://www.apache.org/licenses/LICENSE-2.0  | 
9  |  |  *  | 
10  |  |  * Unless required by applicable law or agreed to in writing, software  | 
11  |  |  * distributed under the License is distributed on an "AS IS" BASIS,  | 
12  |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  | 
13  |  |  * See the License for the specific language governing permissions and  | 
14  |  |  * limitations under the License.  | 
15  |  |  */  | 
16  |  |  | 
17  |  | #pragma once  | 
18  |  |  | 
19  |  | #include <sstream>  | 
20  |  |  | 
21  |  | #include "xml.pb.h"  | 
22  |  |  | 
23  |  | namespace xmlProtoFuzzer { | 
24  |  | class ProtoConverter  | 
25  |  | { | 
26  |  | public:  | 
27  | 8.25k  |   ProtoConverter() = default;  | 
28  |  |  | 
29  |  |   ProtoConverter(ProtoConverter const&) = delete;  | 
30  |  |  | 
31  |  |   ProtoConverter(ProtoConverter&&) = delete;  | 
32  |  |  | 
33  |  |   std::string protoToString(XmlDocument const&);  | 
34  |  |  | 
35  |  | private:  | 
36  |  |   void visit(Prolog const&);  | 
37  |  |  | 
38  |  |   void visit(ProcessingInstruction const&);  | 
39  |  |  | 
40  |  |   void visit(ExternalId const&);  | 
41  |  |  | 
42  |  |   void visit(DocTypeDecl const&);  | 
43  |  |  | 
44  |  |   void visit(VersionNum const&);  | 
45  |  |  | 
46  |  |   void visit(Encodings const&);  | 
47  |  |  | 
48  |  |   void visit(Misc const&);  | 
49  |  |  | 
50  |  |   void visit(KeyValue const&);  | 
51  |  |  | 
52  |  |   void visit(Element const&);  | 
53  |  |  | 
54  |  |   void visit(ElementDecl const&);  | 
55  |  |  | 
56  |  |   void visit(AttValue const&);  | 
57  |  |  | 
58  |  |   void visit(DefaultDecl const&);  | 
59  |  |  | 
60  |  |   void visit(AttDef const&);  | 
61  |  |  | 
62  |  |   void visit(AttListDecl const&);  | 
63  |  |  | 
64  |  |   void visit(NotationDecl const&);  | 
65  |  |  | 
66  |  |   void visit(EntityDecl const&);  | 
67  |  |  | 
68  |  |   void visit(EntityValue const&);  | 
69  |  |  | 
70  |  |   void visit(EntityDef const&);  | 
71  |  |  | 
72  |  |   void visit(PEDef const&);  | 
73  |  |  | 
74  |  |   void visit(NDataDecl const&);  | 
75  |  |  | 
76  |  |   void visit(ConditionalSect const&);  | 
77  |  |  | 
78  |  |   void visit(OneExtSubsetDecl const&);  | 
79  |  |  | 
80  |  |   void visit(ExtSubsetDecl const&);  | 
81  |  |  | 
82  |  |   void visit(MarkupDecl const&);  | 
83  |  |  | 
84  |  |   void visit(CData const&);  | 
85  |  |  | 
86  |  |   void visit(Content const&);  | 
87  |  |  | 
88  |  |   void visit(XmlDeclaration const&);  | 
89  |  |  | 
90  |  |   void visit(XmlDocument const&);  | 
91  |  |  | 
92  |  |   template <typename T>  | 
93  | 278k  |   bool isValid(T const& messageType) { | 
94  | 278k  |     return T::Type_IsValid(messageType.type());  | 
95  | 278k  |   } bool xmlProtoFuzzer::ProtoConverter::isValid<xmlProtoFuzzer::AttValue>(xmlProtoFuzzer::AttValue const&) Line  | Count  | Source  |  93  | 5.94k  |   bool isValid(T const& messageType) { |  94  | 5.94k  |     return T::Type_IsValid(messageType.type());  |  95  | 5.94k  |   }  |  
 bool xmlProtoFuzzer::ProtoConverter::isValid<xmlProtoFuzzer::DefaultDecl>(xmlProtoFuzzer::DefaultDecl const&) Line  | Count  | Source  |  93  | 20.6k  |   bool isValid(T const& messageType) { |  94  | 20.6k  |     return T::Type_IsValid(messageType.type());  |  95  | 20.6k  |   }  |  
 bool xmlProtoFuzzer::ProtoConverter::isValid<xmlProtoFuzzer::AttDef>(xmlProtoFuzzer::AttDef const&) Line  | Count  | Source  |  93  | 20.7k  |   bool isValid(T const& messageType) { |  94  | 20.7k  |     return T::Type_IsValid(messageType.type());  |  95  | 20.7k  |   }  |  
 bool xmlProtoFuzzer::ProtoConverter::isValid<xmlProtoFuzzer::EntityValue>(xmlProtoFuzzer::EntityValue const&) Line  | Count  | Source  |  93  | 3.88k  |   bool isValid(T const& messageType) { |  94  | 3.88k  |     return T::Type_IsValid(messageType.type());  |  95  | 3.88k  |   }  |  
 bool xmlProtoFuzzer::ProtoConverter::isValid<xmlProtoFuzzer::EntityDecl>(xmlProtoFuzzer::EntityDecl const&) Line  | Count  | Source  |  93  | 10.9k  |   bool isValid(T const& messageType) { |  94  | 10.9k  |     return T::Type_IsValid(messageType.type());  |  95  | 10.9k  |   }  |  
 bool xmlProtoFuzzer::ProtoConverter::isValid<xmlProtoFuzzer::ConditionalSect>(xmlProtoFuzzer::ConditionalSect const&) Line  | Count  | Source  |  93  | 9.07k  |   bool isValid(T const& messageType) { |  94  | 9.07k  |     return T::Type_IsValid(messageType.type());  |  95  | 9.07k  |   }  |  
 bool xmlProtoFuzzer::ProtoConverter::isValid<xmlProtoFuzzer::Element>(xmlProtoFuzzer::Element const&) Line  | Count  | Source  |  93  | 185k  |   bool isValid(T const& messageType) { |  94  | 185k  |     return T::Type_IsValid(messageType.type());  |  95  | 185k  |   }  |  
 bool xmlProtoFuzzer::ProtoConverter::isValid<xmlProtoFuzzer::ExternalId>(xmlProtoFuzzer::ExternalId const&) Line  | Count  | Source  |  93  | 13.2k  |   bool isValid(T const& messageType) { |  94  | 13.2k  |     return T::Type_IsValid(messageType.type());  |  95  | 13.2k  |   }  |  
 bool xmlProtoFuzzer::ProtoConverter::isValid<xmlProtoFuzzer::VersionNum>(xmlProtoFuzzer::VersionNum const&) Line  | Count  | Source  |  93  | 8.25k  |   bool isValid(T const& messageType) { |  94  | 8.25k  |     return T::Type_IsValid(messageType.type());  |  95  | 8.25k  |   }  |  
  | 
96  |  |  | 
97  |  |   std::string removeNonAscii(std::string const&);  | 
98  |  |   std::string getUri(Element_Id _x);  | 
99  |  |   std::string getPredefined(Element_Id _x, std::string const&);  | 
100  |  |  | 
101  |  |   std::ostringstream m_output;  | 
102  |  |  | 
103  |  |   static constexpr auto s_XInclude = "xmlns:xi=\"http://www.w3.org/2001/XInclude\"";  | 
104  |  | };  | 
105  |  | }  | 
106  |  |  |