LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
Abstract/Parser.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 *
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#ifndef LIEF_ABSTRACT_PARSER_H
16#define LIEF_ABSTRACT_PARSER_H
17
18#include <string_view>
19#include <cstdint>
20#include <memory>
21#include <vector>
22
23#include "LIEF/path.hpp"
24#include "LIEF/visibility.h"
25
26namespace LIEF {
27class BinaryStream;
28class Binary;
29
31class LIEF_API Parser {
32 public:
37 static std::unique_ptr<Binary> parse(std::string_view filename);
38
41 template<class PathT, enable_if_path_t<PathT> = 0>
42 static std::unique_ptr<Binary> parse(const PathT& filename) {
43 return parse(filename.string());
44 }
45
46
51 static std::unique_ptr<Binary> parse(const std::vector<uint8_t>& raw);
52
57 static std::unique_ptr<Binary> parse(std::unique_ptr<BinaryStream> stream);
58
59 protected:
60 Parser(std::string_view file);
61 uint64_t binary_size_ = 0;
62
63 ~Parser() = default;
64 Parser();
65};
66}
67
68#endif
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:34
Generic interface representing a binary executable.
Definition Abstract/Binary.hpp:60
static std::unique_ptr< Binary > parse(const std::vector< uint8_t > &raw)
Construct an LIEF::Binary from the given raw data.
static std::unique_ptr< Binary > parse(std::unique_ptr< BinaryStream > stream)
Construct an LIEF::Binary from the given stream.
static std::unique_ptr< Binary > parse(std::string_view filename)
Construct an LIEF::Binary from the given filename.
static std::unique_ptr< Binary > parse(const PathT &filename)
Same as parse(std::string_view) but the file is given as a std::filesystem::path.
Definition Abstract/Parser.hpp:42
LIEF namespace.
Definition Abstract/Binary.hpp:41
#define LIEF_API
Definition visibility.h:44