LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
SourceVersion.hpp
Go to the documentation of this file.
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
24
25namespace LIEF {
26namespace MachO {
27
28namespace details {
29struct source_version_command;
30}
31
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
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:122
Class that represents the MachO LoadCommand::TYPE::SOURCE_VERSION This command is used to provide the...
Definition SourceVersion.hpp:35
SourceVersion & operator=(const SourceVersion &copy)=default
void accept(Visitor &visitor) const override
std::ostream & print(std::ostream &os) const override
void version(const version_t &version)
Definition SourceVersion.hpp:57
SourceVersion(const details::source_version_command &version_cmd)
SourceVersion(const SourceVersion &copy)=default
static bool classof(const LoadCommand *cmd)
Definition SourceVersion.hpp:65
std::unique_ptr< LoadCommand > clone() const override
Definition SourceVersion.hpp:47
const version_t & version() const
Return the version as an array.
Definition SourceVersion.hpp:54
~SourceVersion() override=default
std::array< uint32_t, 5 > version_t
Version is an array of 5 integers.
Definition SourceVersion.hpp:39
Definition Visitor.hpp:224
LIEF namespace.
Definition Abstract/Binary.hpp:32
#define LIEF_API
Definition visibility.h:41