|
| 1 | +/* Copyright 2017 J.Rieck (based on R. Thomas's work) |
| 2 | + * Copyright 2017 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 | +#include <numeric> |
| 17 | +#include <iomanip> |
| 18 | + |
| 19 | +#include "LIEF/visitors/Hash.hpp" |
| 20 | + |
| 21 | +#include "LIEF/MachO/RPathCommand.hpp" |
| 22 | + |
| 23 | +namespace LIEF { |
| 24 | +namespace MachO { |
| 25 | + |
| 26 | +RPathCommand::RPathCommand(void) = default; |
| 27 | +RPathCommand& RPathCommand::operator=(const RPathCommand&) = default; |
| 28 | +RPathCommand::RPathCommand(const RPathCommand&) = default; |
| 29 | +RPathCommand::~RPathCommand(void) = default; |
| 30 | + |
| 31 | +RPathCommand::RPathCommand(const rpath_command *rpathCmd) : |
| 32 | + LoadCommand::LoadCommand{static_cast<LOAD_COMMAND_TYPES>(rpathCmd->cmd), rpathCmd->cmdsize} |
| 33 | +{ |
| 34 | +} |
| 35 | + |
| 36 | +const std::string& RPathCommand::path(void) const { |
| 37 | + return this->path_; |
| 38 | +} |
| 39 | + |
| 40 | +void RPathCommand::path(const std::string& path) { |
| 41 | + this->path_ = path; |
| 42 | +} |
| 43 | + |
| 44 | + |
| 45 | +void RPathCommand::accept(Visitor& visitor) const { |
| 46 | + LoadCommand::accept(visitor); |
| 47 | + visitor.visit(this->path()); |
| 48 | +} |
| 49 | + |
| 50 | + |
| 51 | +bool RPathCommand::operator==(const RPathCommand& rhs) const { |
| 52 | + size_t hash_lhs = Hash::hash(*this); |
| 53 | + size_t hash_rhs = Hash::hash(rhs); |
| 54 | + return hash_lhs == hash_rhs; |
| 55 | +} |
| 56 | + |
| 57 | +bool RPathCommand::operator!=(const RPathCommand& rhs) const { |
| 58 | + return not (*this == rhs); |
| 59 | +} |
| 60 | + |
| 61 | + |
| 62 | +std::ostream& RPathCommand::print(std::ostream& os) const { |
| 63 | + LoadCommand::print(os); |
| 64 | + os << std::left |
| 65 | + << std::setw(10) << "Path: " << this->path(); |
| 66 | + return os; |
| 67 | +} |
| 68 | + |
| 69 | + |
| 70 | +} |
| 71 | +} |
0 commit comments