LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
SourceVersion.hpp
1/* Copyright 2017 - 2024 R. Thomas
2 * Copyright 2017 - 2024 Quarkslab
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#ifndef LIEF_MACHO_SOURCE_VERSION_COMMAND_H
17#define LIEF_MACHO_SOURCE_VERSION_COMMAND_H
18#include <ostream>
19#include <array>
20
21#include "LIEF/visibility.h"
22
23#include "LIEF/MachO/LoadCommand.hpp"
24
25namespace LIEF {
26namespace MachO {
27
28namespace details {
29struct source_version_command;
30}
31
35class LIEF_API SourceVersion : public LoadCommand {
36
37 public:
39 using version_t = std::array<uint32_t, 5>;
40
41 SourceVersion() = default;
42 SourceVersion(const details::source_version_command& version_cmd);
43
44 SourceVersion& operator=(const SourceVersion& copy) = default;
45 SourceVersion(const SourceVersion& copy) = default;
46
47 std::unique_ptr<LoadCommand> clone() const override {
48 return std::unique_ptr<SourceVersion>(new SourceVersion(*this));
49 }
50
51 ~SourceVersion() override = default;
52
54 const version_t& version() const {
55 return version_;
56 }
57 void version(const version_t& version) {
58 version_ = version;
59 }
60
61 void accept(Visitor& visitor) const override;
62
63 std::ostream& print(std::ostream& os) const override;
64
65 static bool classof(const LoadCommand* cmd) {
66 return cmd->command() == LoadCommand::TYPE::SOURCE_VERSION;
67 }
68
69 private:
70 version_t version_ = {0};
71};
72
73}
74}
75#endif
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:36
Class that represents the MachO LoadCommand::TYPE::SOURCE_VERSION This command is used to provide the...
Definition SourceVersion.hpp:35
const version_t & version() const
Return the version as an array.
Definition SourceVersion.hpp:54
std::array< uint32_t, 5 > version_t
Version is an array of 5 integers.
Definition SourceVersion.hpp:39
Definition Visitor.hpp:219
LIEF namespace.
Definition Abstract/Binary.hpp:32