xref: /aosp_15_r20/external/stg/abigail_reader.h (revision 9e3b08ae94a55201065475453d799e8b1378bea6)
1 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2 // -*- mode: C++ -*-
3 //
4 // Copyright 2021-2024 Google LLC
5 //
6 // Licensed under the Apache License v2.0 with LLVM Exceptions (the
7 // "License"); you may not use this file except in compliance with the
8 // License.  You may obtain a copy of the License at
9 //
10 //     https://llvm.org/LICENSE.txt
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 //
18 // Author: Giuliano Procida
19 // Author: Ignes Simeonova
20 
21 #ifndef STG_ABIGAIL_READER_H_
22 #define STG_ABIGAIL_READER_H_
23 
24 #include <memory>
25 #include <string>
26 #include <string_view>
27 #include <type_traits>
28 
29 #include <libxml/tree.h>
30 #include "graph.h"
31 #include "runtime.h"
32 
33 namespace stg {
34 namespace abixml {
35 
36 Id ProcessDocument(Graph& graph, xmlDocPtr document);
37 Id Read(Runtime& runtime, Graph& graph, const std::string& path);
38 Id ReadFromString(Runtime& runtime, Graph& graph, std::string_view xml);
39 
40 // Exposed for testing.
41 void Clean(xmlNodePtr root);
42 bool EqualTree(xmlNodePtr left, xmlNodePtr right);
43 bool SubTree(xmlNodePtr left, xmlNodePtr right);
44 using Document =
45     std::unique_ptr<std::remove_pointer_t<xmlDocPtr>, void(*)(xmlDocPtr)>;
46 Document Read(Runtime& runtime, const std::string& path);
47 
48 }  // namespace abixml
49 }  // namespace stg
50 
51 #endif  // STG_ABIGAIL_READER_H_
52