1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
#ifndef INCLUDED_OBJDUMP_
#define INCLUDED_OBJDUMP_
#include <iterator>
#include <bobcat/process>
class ObjDump // merely calls 'objdump',
{ // the iterator range produces all
FBB::Process d_process; // of objdump's output
public:
class const_iterator;
const_iterator begin(); // called in main, passed the output line
const_iterator end(); // to Storage::push_back
ObjDump();
void start();
};
struct ObjDump::const_iterator
{
friend const_iterator ObjDump::begin();
friend const_iterator ObjDump::end();
using iterator_category = std::input_iterator_tag;
using difference_type = std::ptrdiff_t;
using value_type = std::string;
using pointer = value_type *;
using reference = value_type &;
private:
FBB::Process *d_process;
mutable bool d_iterate;
mutable std::string d_line;
const_iterator(FBB::Process *process, bool iterate);
public:
const_iterator &operator++();
bool operator==(const_iterator const &other) const;
bool operator!=(const_iterator const &other) const;
std::string const &operator*() const;
std::string const *operator->() const;
};
inline void ObjDump::start()
{
d_process.start();
}
inline ObjDump::const_iterator ObjDump::begin()
{
return const_iterator(&d_process, true);
}
inline ObjDump::const_iterator ObjDump::end()
{
return const_iterator(&d_process, false);
}
inline bool ObjDump::const_iterator::operator!=(const_iterator const &rhs)
const
{
return not (*this == rhs);
}
inline std::string const &ObjDump::const_iterator::operator*() const
{
return d_line;
}
inline std::string const *ObjDump::const_iterator::operator->() const
{
return &d_line;
}
#endif
|