OpenASIP
2.0
|
#include <SectionWriter.hh>
Static Public Member Functions | |
static void | writeHeader (BinaryStream &stream, const Section *sect, const BinaryWriter *writer) |
static void | writeData (BinaryStream &stream, const Section *sect, const BinaryWriter *writer) |
static void | finalizeBinary (BinaryStream &stream, const Binary *binaryToFinalize, const BinaryWriter *writer) |
Protected Member Functions | |
SectionWriter () | |
virtual | ~SectionWriter () |
virtual const BinaryWriter & | parent () const =0 |
Gets parent of instance which for SectionWriter is created. More... | |
virtual Section::SectionType | type () const =0 |
Returns SectionType that actual reader or writer instance can handle. More... | |
virtual void | finalize (BinaryStream &stream, Section *section) const |
virtual void | actualWriteHeader (BinaryStream &stream, const Section *sect) const =0 |
Does actual writing of sections header. More... | |
virtual void | actualWriteData (BinaryStream &stream, const Section *sect) const =0 |
Does actual writing of sections data. More... | |
Static Protected Member Functions | |
static void | registerSectionWriter (const SectionWriter *sWriter) |
static SectionId | getUniqueSectionId () |
Private Types | |
typedef std::pair< const Section::SectionType, const BinaryWriter * > | MapKey |
Key type for finding values in map of section writers. More... | |
typedef std::map< MapKey, const SectionWriter * > | MapType |
Map type that contains instances of registered section writers. More... | |
Private Member Functions | |
SectionWriter (const SectionWriter &) | |
Static Private Member Functions | |
static const SectionWriter * | findSectionWriter (const Section::SectionType type, const BinaryWriter *bWriter) |
Static Private Attributes | |
static MapType * | prototypes_ = NULL |
Contains section writers for all kinds of sections and all kinds of binrary fromats that are supported. More... | |
Abstract base class for actual section writer classes.
SectionWriter base class stores instances of all registed section writer classes and serve registeration methods for actual SectionWriter instances. Actual section writer classes needs also static instance() method to work correctly.
Definition at line 58 of file SectionWriter.hh.
|
private |
Key type for finding values in map of section writers.
Definition at line 104 of file SectionWriter.hh.
|
private |
Map type that contains instances of registered section writers.
Definition at line 107 of file SectionWriter.hh.
|
protected |
|
protectedvirtual |
|
private |
|
protectedpure virtual |
Does actual writing of sections data.
Implemented in TPEF::TPEFSymbolSectionWriter, TPEF::TPEFDebugSectionWriter, TPEF::TPEFASpaceSectionWriter, TPEF::TPEFRelocSectionWriter, TPEF::TPEFResourceSectionWriter, TPEF::TPEFLineNumSectionWriter, TPEF::TPEFSectionWriter, TPEF::TPEFCodeSectionWriter, TPEF::TPEFDataSectionWriter, and TPEF::TPEFStringSectionWriter.
Referenced by writeData().
|
protectedpure virtual |
Does actual writing of sections header.
Implemented in TPEF::TPEFSectionWriter.
Referenced by writeHeader().
|
protectedvirtual |
Default finalizer method.
This is used, if section does not have its own method defined.
stream | Stream that contains binary to finalize. |
section | Section to finalize. |
Definition at line 192 of file SectionWriter.cc.
Referenced by finalizeBinary().
|
static |
Writes those values to stream, which can't be written before all objects are written down.
This is used for example when some section writer has to update data of other section or sections.
stream | Stream that contains binary to finalize. |
Binary | Binary file which needs finalization. |
writer | Writer, which was used for writing binary. |
Definition at line 99 of file SectionWriter.cc.
References finalize(), findSectionWriter(), TPEF::Binary::section(), TPEF::Binary::sectionCount(), and TPEF::Section::type().
Referenced by TPEF::BinaryWriter::writeBinary().
|
staticprivate |
Finds SectionWriter instance by SectionType and BinaryWriter*.
type | Type of section to find. |
bWriter | BinaryWriter which requested finding section. |
InstanceNotFound | Writer instance was not found. |
Definition at line 129 of file SectionWriter.cc.
References MapTools::containsKey(), prototypes_, and type().
Referenced by finalizeBinary(), writeData(), and writeHeader().
|
staticprotected |
Generates a unique section identification code.
If several files are written out, the section identification codes of each file will be starting from a different numeric code. Never returns the reserved identification code for null/invalid section.
Definition at line 172 of file SectionWriter.cc.
Referenced by TPEF::TPEFSectionWriter::getSectionId().
|
protectedpure virtual |
Gets parent of instance which for SectionWriter is created.
Implemented in TPEF::TPEFSectionWriter.
Referenced by registerSectionWriter().
|
staticprotected |
Registers SectionWriter instance for writing specific section type.
sWriter | Instance to register for writing. |
Definition at line 148 of file SectionWriter.cc.
References assert, MapTools::containsKey(), parent(), prototypes_, and type().
Referenced by TPEF::TPEFASpaceSectionWriter::TPEFASpaceSectionWriter(), TPEF::TPEFCodeSectionWriter::TPEFCodeSectionWriter(), TPEF::TPEFDataSectionWriter::TPEFDataSectionWriter(), TPEF::TPEFDebugSectionWriter::TPEFDebugSectionWriter(), TPEF::TPEFLEDataSectionWriter::TPEFLEDataSectionWriter(), TPEF::TPEFLineNumSectionWriter::TPEFLineNumSectionWriter(), TPEF::TPEFNullSectionWriter::TPEFNullSectionWriter(), TPEF::TPEFRelocSectionWriter::TPEFRelocSectionWriter(), TPEF::TPEFResourceSectionWriter::TPEFResourceSectionWriter(), TPEF::TPEFStringSectionWriter::TPEFStringSectionWriter(), TPEF::TPEFSymbolSectionWriter::TPEFSymbolSectionWriter(), and TPEF::TPEFUDataSectionWriter::TPEFUDataSectionWriter().
|
protectedpure virtual |
Returns SectionType that actual reader or writer instance can handle.
Implemented in TPEF::TPEFSectionWriter, TPEF::TPEFUDataSectionWriter, TPEF::TPEFCodeSectionWriter, TPEF::TPEFDataSectionWriter, TPEF::TPEFASpaceSectionWriter, TPEF::TPEFRelocSectionWriter, TPEF::TPEFResourceSectionWriter, TPEF::TPEFStringSectionWriter, TPEF::TPEFSymbolSectionWriter, TPEF::TPEFDebugSectionWriter, TPEF::TPEFLineNumSectionWriter, TPEF::TPEFNullSectionWriter, and TPEF::TPEFLEDataSectionWriter.
Referenced by findSectionWriter(), and registerSectionWriter().
|
static |
Finds correct SectionWriter instance and command it to write section data.
stream | Stream where to write. |
sect | Section which data will be written. |
writer | BinaryWriter which filetype we want to write. |
InstanceNotFound | If there wasn't found any writer for section. |
Definition at line 79 of file SectionWriter.cc.
References actualWriteData(), findSectionWriter(), and TPEF::Section::type().
Referenced by TPEF::TPEFWriter::actualWriteBinary().
|
static |
Finds correct SectionWriter instance and use it to write section header.
stream | Stream where to write. |
sect | Section which header will be written. |
writer | BinaryWriter which filetype we want to write. |
InstanceNotFound | If there wasn't found any writer for section. |
Definition at line 62 of file SectionWriter.cc.
References actualWriteHeader(), findSectionWriter(), and TPEF::Section::type().
Referenced by TPEF::TPEFWriter::actualWriteBinary().
|
staticprivate |
Contains section writers for all kinds of sections and all kinds of binrary fromats that are supported.
Definition at line 116 of file SectionWriter.hh.
Referenced by findSectionWriter(), and registerSectionWriter().