OpenASIP
2.0
|
#include <SectionReader.hh>
Public Types | |
typedef BinaryReader::Length | Length |
Public Member Functions | |
virtual | ~SectionReader () |
Static Public Member Functions | |
static void | readSection (BinaryStream &stream, Section *section, BinaryReader *reader) |
static void | finalizeBinary (Binary *binaryToFinalize, BinaryReader *reader) |
Protected Member Functions | |
SectionReader () | |
virtual void | readData (BinaryStream &stream, Section *section) const =0 |
Does actual reading part for constructing section. More... | |
virtual BinaryReader * | parent () const =0 |
Returns binary reader whose sections actual section reader reads. More... | |
virtual Section::SectionType | type () const =0 |
Returns type (TPEF) section which actual section reader reads. More... | |
virtual void | finalize (Section *section) const |
Static Protected Member Functions | |
static const SectionReader * | findSectionReader (const Section::SectionType type, const BinaryReader *bReader) |
static void | registerSectionReader (const SectionReader *sReader) |
Private Types | |
typedef std::pair< const Section::SectionType, const BinaryReader * > | MapKey |
Key type for finding values in map of section readers. More... | |
typedef std::map< MapKey, const SectionReader * > | MapType |
Map type that contains instances of registered section readers. More... | |
Private Member Functions | |
SectionReader (const SectionReader &) | |
Copying is not allowed. More... | |
Static Private Attributes | |
static MapType * | prototypes_ = NULL |
Contains section readers for all kinds of sections and all kinds of binary formats that are supported. More... | |
Abstract base class for SectionReaders.
Implements user friendly interface for registration and finding concrete SectionReader instances. Defines also interface for reading sections so there is no need to know interface or even type of concrete SectionReaders.
Definition at line 56 of file SectionReader.hh.
Definition at line 58 of file SectionReader.hh.
|
private |
Key type for finding values in map of section readers.
Definition at line 94 of file SectionReader.hh.
|
private |
Map type that contains instances of registered section readers.
Definition at line 97 of file SectionReader.hh.
|
virtual |
|
protected |
|
private |
Copying is not allowed.
|
protectedvirtual |
Default finalizer method all sections.
Does nothing. This method is runned for every read section after body of every section is read and references are resolved once.
section | Section to finalize. |
Reimplemented in TPEF::AOutSymbolSectionReader, TPEF::AOutRelocationSectionReader, and TPEF::TPEFRelocSectionReader.
Definition at line 169 of file SectionReader.cc.
Referenced by finalizeBinary().
|
static |
Finalizes binary whose all data is read and resolved.
bin | Binary to resolve. |
reader | Reader which was used for reading. |
Definition at line 99 of file SectionReader.cc.
References finalize(), findSectionReader(), TPEF::Binary::section(), TPEF::Binary::sectionCount(), and TPEF::Section::type().
Referenced by TPEF::BinaryReader::readBinary().
|
staticprotected |
Finds SectionReader instance by SectionType and BinaryReader*.
type | Type of section to find. |
reader | BinaryReader which requested finding section. |
InstanceNotFound | Reader instance was not found. |
Definition at line 126 of file SectionReader.cc.
References MapTools::containsKey(), prototypes_, and type().
Referenced by finalizeBinary(), and readSection().
|
protectedpure virtual |
Returns binary reader whose sections actual section reader reads.
Implemented in TPEF::TPEFSectionReader, and TPEF::AOutSectionReader.
Referenced by registerSectionReader().
|
protectedpure virtual |
Does actual reading part for constructing section.
Implemented in TPEF::AOutSymbolSectionReader, TPEF::AOutRelocationSectionReader, TPEF::AOutTextSectionReader, TPEF::AOutDataSectionReader, TPEF::TPEFSectionReader, TPEF::AOutStringSectionReader, TPEF::TPEFRelocSectionReader, TPEF::TPEFCodeSectionReader, TPEF::TPEFLineNumSectionReader, TPEF::TPEFResourceSectionReader, TPEF::TPEFSymbolSectionReader, TPEF::TPEFASpaceSectionReader, TPEF::TPEFDataSectionReader, TPEF::TPEFDebugSectionReader, TPEF::TPEFStringSectionReader, and TPEF::TPEFUDataSectionReader.
Referenced by readSection().
|
static |
Reads a section from BinaryStream.
Finds correct concrete SectionReader object for reading section and uses it for reading.
stream | Stream from which section's data is read. |
section | Section instance where section elements are stored. |
reader | BinaryReader* of file type that we try to read. |
InstanceNotFound | There is no prototype registred for reading. |
UnreachableStream | If reading of section fails. |
KeyAlreadyExists | Key was in use when trying to register object. |
EndOfFile | If end of file were reached while it shouldn't. |
OutOfRange | Some of read values were out of range. |
WrongSubclass | Some class couldn't do what it was asked for. |
UnexpectedValue | If there was unexpected value when reading. |
Definition at line 84 of file SectionReader.cc.
References findSectionReader(), readData(), and TPEF::Section::type().
Referenced by TPEF::TPEFReader::readData().
|
staticprotected |
Registers SectionReader instance for reading specific section type.
reader | Instance to register for reading. |
Definition at line 145 of file SectionReader.cc.
References assert, MapTools::containsKey(), parent(), prototypes_, and type().
Referenced by TPEF::AOutDataSectionReader::AOutDataSectionReader(), TPEF::AOutRelocationSectionReader::AOutRelocationSectionReader(), TPEF::AOutStringSectionReader::AOutStringSectionReader(), TPEF::AOutSymbolSectionReader::AOutSymbolSectionReader(), TPEF::AOutTextSectionReader::AOutTextSectionReader(), TPEF::TPEFASpaceSectionReader::TPEFASpaceSectionReader(), TPEF::TPEFCodeSectionReader::TPEFCodeSectionReader(), TPEF::TPEFDataSectionReader::TPEFDataSectionReader(), TPEF::TPEFDebugSectionReader::TPEFDebugSectionReader(), TPEF::TPEFLEDataSectionReader::TPEFLEDataSectionReader(), TPEF::TPEFLineNumSectionReader::TPEFLineNumSectionReader(), TPEF::TPEFNullSectionReader::TPEFNullSectionReader(), TPEF::TPEFRelocSectionReader::TPEFRelocSectionReader(), TPEF::TPEFResourceSectionReader::TPEFResourceSectionReader(), TPEF::TPEFStringSectionReader::TPEFStringSectionReader(), TPEF::TPEFSymbolSectionReader::TPEFSymbolSectionReader(), and TPEF::TPEFUDataSectionReader::TPEFUDataSectionReader().
|
protectedpure virtual |
Returns type (TPEF) section which actual section reader reads.
Implemented in TPEF::AOutSymbolSectionReader, TPEF::AOutRelocationSectionReader, TPEF::AOutDataSectionReader, TPEF::AOutTextSectionReader, TPEF::AOutStringSectionReader, TPEF::TPEFRelocSectionReader, TPEF::TPEFCodeSectionReader, TPEF::TPEFLineNumSectionReader, TPEF::TPEFResourceSectionReader, TPEF::TPEFSymbolSectionReader, TPEF::TPEFASpaceSectionReader, TPEF::TPEFDataSectionReader, TPEF::TPEFDebugSectionReader, TPEF::TPEFStringSectionReader, TPEF::TPEFUDataSectionReader, TPEF::TPEFNullSectionReader, and TPEF::TPEFLEDataSectionReader.
Referenced by findSectionReader(), and registerSectionReader().
|
staticprivate |
Contains section readers for all kinds of sections and all kinds of binary formats that are supported.
Definition at line 101 of file SectionReader.hh.
Referenced by findSectionReader(), and registerSectionReader().