16#ifndef LIEF_MACHO_FAT_BINARY_H
17#define LIEF_MACHO_FAT_BINARY_H
60 return binaries_.size();
65 return binaries_.empty();
84 for (
auto& bin : binaries_) {
96 return const_cast<Binary*
>(
static_cast<const FatBinary*
>(
this)->at(index));
100 if (index >=
size()) {
103 return binaries_[index].
get();
107 return const_cast<Binary*
>(
static_cast<const FatBinary*
>(
this)->back());
110 return binaries_.empty() ? nullptr : binaries_.back().
get();
114 return const_cast<Binary*
>(
static_cast<const FatBinary*
>(
this)->front());
118 return binaries_.empty() ? nullptr : binaries_.front().
get();
132 std::unique_ptr<Binary>
take(
size_t index);
140 void write(
const std::string& filename);
143 std::vector<uint8_t>
raw();
Class which represents a MachO binary.
Definition MachO/Binary.hpp:88
const LoadCommand * get(LoadCommand::TYPE type) const
Return the LoadCommand associated with the given LoadCommand::TYPE or a nullptr if the command can't ...
Class used to rebuild a Mach-O file.
Definition MachO/Builder.hpp:63
it_binaries end()
Definition FatBinary.hpp:75
Binary * front()
Definition FatBinary.hpp:113
std::unique_ptr< Binary > pop_back()
Get a pointer to the last MachO::Binary object presents in this Fat Binary. It returns a nullptr if n...
bool empty() const
Checks whether this object contains MachO::Binary.
Definition FatBinary.hpp:64
std::unique_ptr< Binary > take(Header::CPU_TYPE cpu)
Take the underlying MachO::Binary that matches the given architecture If no binary with the architect...
std::vector< uint8_t > raw()
Reconstruct the Fat binary object and return his content as bytes.
FatBinary(const FatBinary &)=delete
friend std::ostream & operator<<(std::ostream &os, const FatBinary &fatbinary)
ref_iterator< binaries_t &, Binary * > it_binaries
Iterator that outputs Binary&.
Definition FatBinary.hpp:48
std::unique_ptr< Binary > take(size_t index)
Extract a MachO::Binary object. Gives ownership to the caller, and remove it from this FatBinary obje...
const Binary * at(size_t index) const
Definition FatBinary.hpp:99
const Binary * back() const
Definition FatBinary.hpp:109
Binary * operator[](size_t index)
Definition FatBinary.hpp:121
it_binaries begin()
Definition FatBinary.hpp:68
friend class Builder
Definition FatBinary.hpp:40
it_const_binaries begin() const
Definition FatBinary.hpp:71
std::vector< std::unique_ptr< Binary > > binaries_t
Internal container used to store Binary objects within a Fat Mach-O.
Definition FatBinary.hpp:45
Binary * back()
Definition FatBinary.hpp:106
const Binary * front() const
Definition FatBinary.hpp:117
void write(const std::string &filename)
Reconstruct the Fat binary object and write it in filename.
FatBinary & operator=(const FatBinary &)=delete
friend class LIEF::Parser
Definition FatBinary.hpp:38
it_const_binaries end() const
Definition FatBinary.hpp:79
const_ref_iterator< const binaries_t &, Binary * > it_const_binaries
Iterator that outputs const Binary&.
Definition FatBinary.hpp:51
Binary * at(size_t index)
Get a pointer to the MachO::Binary specified by the index. It returns a nullptr if the binary does no...
Definition FatBinary.hpp:95
size_t size() const
Number of MachO::Binary wrapped by this object.
Definition FatBinary.hpp:59
const Binary * operator[](size_t index) const
Definition FatBinary.hpp:124
void release_all_binaries()
Definition FatBinary.hpp:83
The main interface to parse a Mach-O binary.
Definition MachO/Parser.hpp:42
Main interface to parse an executable regardless of its format.
Definition Abstract/Parser.hpp:30
Iterator which returns reference on container's values.
Definition iterators.hpp:46
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
LIEF namespace.
Definition Abstract/Binary.hpp:40
ref_iterator< CT, U, typename decay_t< CT >::const_iterator > const_ref_iterator
Iterator which return const ref on container's values.
Definition iterators.hpp:257
#define LIEF_API
Definition visibility.h:41
#define LIEF_LOCAL
Definition visibility.h:42