OpenASIP  2.0
Protected Member Functions | Private Member Functions | Static Private Attributes | List of all members
TPEF::TPEFStringSectionReader Class Reference

#include <TPEFStringSectionReader.hh>

Inheritance diagram for TPEF::TPEFStringSectionReader:
Inheritance graph
Collaboration diagram for TPEF::TPEFStringSectionReader:
Collaboration graph

Protected Member Functions

 TPEFStringSectionReader ()
 
virtual ~TPEFStringSectionReader ()
 
virtual void readData (BinaryStream &stream, Section *section) const
 
virtual Section::SectionType type () const
 
- Protected Member Functions inherited from TPEF::TPEFSectionReader
 TPEFSectionReader ()
 
virtual BinaryReaderparent () const
 
virtual void readInfo (BinaryStream &stream, Section *sect) const
 
- Protected Member Functions inherited from TPEF::SectionReader
 SectionReader ()
 
virtual void finalize (Section *section) const
 

Private Member Functions

 TPEFStringSectionReader (const TPEFStringSectionReader &)
 Copying not allowed. More...
 
TPEFStringSectionReaderoperator= (TPEFStringSectionReader &)
 Assignment not allowed. More...
 

Static Private Attributes

static TPEFStringSectionReader proto_
 Prototype instance of TPEFStringSectionReader to be registered to SectionReader. More...
 

Additional Inherited Members

- Public Types inherited from TPEF::SectionReader
typedef BinaryReader::Length Length
 
- Public Member Functions inherited from TPEF::TPEFSectionReader
virtual ~TPEFSectionReader ()
 
- Public Member Functions inherited from TPEF::SectionReader
virtual ~SectionReader ()
 
- Static Public Member Functions inherited from TPEF::SectionReader
static void readSection (BinaryStream &stream, Section *section, BinaryReader *reader)
 
static void finalizeBinary (Binary *binaryToFinalize, BinaryReader *reader)
 
- Static Protected Member Functions inherited from TPEF::TPEFSectionReader
static const Headerheader ()
 
- Static Protected Member Functions inherited from TPEF::SectionReader
static const SectionReaderfindSectionReader (const Section::SectionType type, const BinaryReader *bReader)
 
static void registerSectionReader (const SectionReader *sReader)
 

Detailed Description

Reads string section from TPEF binary file.

Definition at line 46 of file TPEFStringSectionReader.hh.

Constructor & Destructor Documentation

◆ TPEFStringSectionReader() [1/2]

TPEF::TPEFStringSectionReader::TPEFStringSectionReader ( )
protected

Constructor.

Registers itself to SectionReader.

Definition at line 55 of file TPEFStringSectionReader.cc.

References TPEF::SectionReader::registerSectionReader().

Here is the call graph for this function:

◆ ~TPEFStringSectionReader()

TPEF::TPEFStringSectionReader::~TPEFStringSectionReader ( )
protectedvirtual

Destructor.

Definition at line 62 of file TPEFStringSectionReader.cc.

62  {
63 }

◆ TPEFStringSectionReader() [2/2]

TPEF::TPEFStringSectionReader::TPEFStringSectionReader ( const TPEFStringSectionReader )
private

Copying not allowed.

Member Function Documentation

◆ operator=()

TPEFStringSectionReader& TPEF::TPEFStringSectionReader::operator= ( TPEFStringSectionReader )
private

Assignment not allowed.

◆ readData()

void TPEF::TPEFStringSectionReader::readData ( BinaryStream stream,
Section section 
) const
protectedvirtual

Reads section data from TPEF binary file.

Parameters
streamStream to be read from.
sectionSection where the information is to be stored.
Exceptions
UnreachableStreamIf reading of section fails.
KeyAlreadyExistsKey was in use when trying to register object.
EndOfFileIf end of file were reached while it shouldn't.
OutOfRangeSome of read values were out of range.
WrongSubclassSome class couldn't do what it was asked for.
UnexpectedValueIf there was unexpected value when reading.

Reimplemented from TPEF::TPEFSectionReader.

Definition at line 88 of file TPEFStringSectionReader.cc.

89  {
90  // base classes implementation must be called
91  TPEFSectionReader::readData(stream, section);
92 
93  StringSection* stringSection = dynamic_cast<StringSection*>(section);
94  assert(stringSection != NULL);
95 
96  // check that link section is defined properly
97  assert(header().linkId == 0);
98 
99  if (!section->noBits()) {
100  while (stream.readPosition() <
101  header().bodyOffset + header().bodyLength) {
102 
103  stringSection->addByte(stream.readByte());
104  }
105 
106  assert(stringSection->byte(stringSection->chunk(0)) == 0);
107  }
108 
109  // if nobits flag was set, add zero string to start of section to make
110  // references valid (many sections needs string section
111  // e.g. symbol section).
112  if (stringSection->empty()) {
113  stringSection->addByte(0);
114  }
115 }

References TPEF::DataSection::addByte(), assert, TPEF::DataSection::byte(), TPEF::RawSection::chunk(), TPEF::RawSection::empty(), TPEF::TPEFSectionReader::header(), TPEF::Section::noBits(), TPEF::BinaryStream::readByte(), TPEF::TPEFSectionReader::readData(), and TPEF::BinaryStream::readPosition().

Here is the call graph for this function:

◆ type()

Section::SectionType TPEF::TPEFStringSectionReader::type ( ) const
protectedvirtual

Returns the type of section it is meant to read.

Returns
The type of section it can read.

Implements TPEF::SectionReader.

Definition at line 71 of file TPEFStringSectionReader.cc.

71  {
72  return Section::ST_STRTAB;
73 }

References TPEF::Section::ST_STRTAB.

Member Data Documentation

◆ proto_

TPEFStringSectionReader TPEF::TPEFStringSectionReader::proto_
staticprivate

Prototype instance of TPEFStringSectionReader to be registered to SectionReader.

Definition at line 63 of file TPEFStringSectionReader.hh.


The documentation for this class was generated from the following files:
TPEF::TPEFSectionReader::TPEFSectionReader
TPEFSectionReader()
Definition: TPEFSectionReader.cc:50
assert
#define assert(condition)
Definition: Application.hh:86
TPEF::SectionReader::registerSectionReader
static void registerSectionReader(const SectionReader *sReader)
Definition: SectionReader.cc:145
TPEF::TPEFSectionReader::readData
virtual void readData(BinaryStream &stream, Section *section) const
Definition: TPEFSectionReader.cc:86
TPEF::Section::ST_STRTAB
@ ST_STRTAB
String table.
Definition: Section.hh:71
TPEF::TPEFSectionReader::header
static const Header & header()
Definition: TPEFSectionReader.cc:174