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

#include <TPEFStringSectionWriter.hh>

Inheritance diagram for TPEF::TPEFStringSectionWriter:
Inheritance graph
Collaboration diagram for TPEF::TPEFStringSectionWriter:
Collaboration graph

Protected Member Functions

 TPEFStringSectionWriter ()
 
virtual ~TPEFStringSectionWriter ()
 
virtual Section::SectionType type () const
 
virtual void actualWriteData (BinaryStream &stream, const Section *sect) const
 
virtual Word elementSize (const Section *section) const
 
- Protected Member Functions inherited from TPEF::TPEFSectionWriter
 TPEFSectionWriter ()
 
virtual ~TPEFSectionWriter ()
 
virtual const BinaryWriterparent () const
 
virtual void actualWriteHeader (BinaryStream &stream, const Section *sect) const
 
virtual void createKeys (const Section *sect) const
 
virtual void writeSize (BinaryStream &stream, const Section *sect) const
 
virtual void writeInfo (BinaryStream &stream, const Section *sect) const
 
virtual SectionId getSectionId () const
 
- Protected Member Functions inherited from TPEF::SectionWriter
 SectionWriter ()
 
virtual ~SectionWriter ()
 
virtual void finalize (BinaryStream &stream, Section *section) const
 

Private Member Functions

 TPEFStringSectionWriter (const TPEFStringSectionWriter &)
 Copying not allowed. More...
 
TPEFStringSectionWriteroperator= (const TPEFStringSectionWriter &)
 Assignment not allowed. More...
 

Static Private Attributes

static const TPEFStringSectionWriter instance_
 Unique instance of class. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from TPEF::SectionWriter
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)
 
- Static Protected Member Functions inherited from TPEF::SectionWriter
static void registerSectionWriter (const SectionWriter *sWriter)
 
static SectionId getUniqueSectionId ()
 

Detailed Description

Writes the contents of TPEF string section to stream.

Definition at line 47 of file TPEFStringSectionWriter.hh.

Constructor & Destructor Documentation

◆ TPEFStringSectionWriter() [1/2]

TPEF::TPEFStringSectionWriter::TPEFStringSectionWriter ( )
protected

Constructor.

Registers itself to SectionWriter.

Definition at line 57 of file TPEFStringSectionWriter.cc.

57  : TPEFSectionWriter() {
59 }

References TPEF::SectionWriter::registerSectionWriter().

Here is the call graph for this function:

◆ ~TPEFStringSectionWriter()

TPEF::TPEFStringSectionWriter::~TPEFStringSectionWriter ( )
protectedvirtual

Destructor.

Definition at line 64 of file TPEFStringSectionWriter.cc.

64  {
65 }

◆ TPEFStringSectionWriter() [2/2]

TPEF::TPEFStringSectionWriter::TPEFStringSectionWriter ( const TPEFStringSectionWriter )
private

Copying not allowed.

Member Function Documentation

◆ actualWriteData()

void TPEF::TPEFStringSectionWriter::actualWriteData ( BinaryStream stream,
const Section sect 
) const
protectedvirtual

Writes the data of the section to the stream.

Parameters
streamThe stream to be written.
sectThe section which data is written to stream.

Reimplemented from TPEF::TPEFSectionWriter.

Definition at line 84 of file TPEFStringSectionWriter.cc.

86  {
87 
88  const StringSection* stringSection =
89  dynamic_cast<const StringSection*>(sect);
90 
91  assert(stringSection != NULL);
92 
93  FileOffset startOffset = stream.writePosition();
94 
95  // file offset to data of section
96  SafePointer::addObjectReference(FileOffsetKey(startOffset),
97  sect->chunk(0));
98 
99  SectionOffset sectOffset = 0;
100  SectionKey sKey = SafePointer::sectionKeyFor(stringSection);
101  SectionId id = sKey.sectionId();
102 
103  // first byte
104  assert(stringSection->byte(stringSection->chunk(0)) == 0);
105 
106  // last byte must be also zero
107  assert(stringSection->byte(
108  stringSection->chunk(
109  stringSection->length() - 1)) == 0);
110 
111  for (unsigned int i = 0; i < stringSection->length(); i++) {
112  sectOffset = stream.writePosition() - startOffset;
113 
114  Chunk* chunk = NULL;
115 
116  try {
117  chunk = stringSection->chunk(sectOffset);
118  } catch (const NotChunkable& n) {
119  bool sectionToBeWrittenIsNotChunkable = false;
120  assert(sectionToBeWrittenIsNotChunkable);
121  }
122 
123  if (SafePointer::isReferenced(chunk)) {
124 
126  SectionOffsetKey(id, sectOffset), chunk);
127  }
128 
129  stream.writeByte(stringSection->byte(chunk));
130  }
131 
133  stringSection, stream.writePosition() - startOffset);
134 }

References TPEF::ReferenceManager::SafePointer::addObjectReference(), assert, TPEF::DataSection::byte(), TPEF::Section::chunk(), TPEF::RawSection::chunk(), TPEF::ReferenceManager::SafePointer::isReferenced(), TPEF::DataSection::length(), TPEF::ReferenceManager::SectionKey::sectionId(), TPEF::ReferenceManager::SafePointer::sectionKeyFor(), TPEF::SectionSizeReplacer::setSize(), TPEF::BinaryStream::writeByte(), and TPEF::BinaryStream::writePosition().

Here is the call graph for this function:

◆ elementSize()

Word TPEF::TPEFStringSectionWriter::elementSize ( const Section section) const
protectedvirtual

Returns size of char.

Returns
Size of char.

Reimplemented from TPEF::TPEFSectionWriter.

Definition at line 142 of file TPEFStringSectionWriter.cc.

142  {
143  return sizeof(char);
144 }

◆ operator=()

TPEFStringSectionWriter& TPEF::TPEFStringSectionWriter::operator= ( const TPEFStringSectionWriter )
private

Assignment not allowed.

◆ type()

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

Returns the type of the section this writer can write.

Returns
The type of the section writer can write.

Implements TPEF::TPEFSectionWriter.

Definition at line 73 of file TPEFStringSectionWriter.cc.

73  {
74  return Section::ST_STRTAB;
75 }

References TPEF::Section::ST_STRTAB.

Member Data Documentation

◆ instance_

const TPEFStringSectionWriter TPEF::TPEFStringSectionWriter::instance_
staticprivate

Unique instance of class.

Definition at line 66 of file TPEFStringSectionWriter.hh.


The documentation for this class was generated from the following files:
TPEF::SectionId
HalfWord SectionId
Type for storing binary file section ids.
Definition: TPEFBaseType.hh:43
TPEF::ReferenceManager::SafePointer::isReferenced
static bool isReferenced(const SafePointable *object)
Definition: SafePointer.cc:282
TPEF::ReferenceManager::SafePointer::addObjectReference
static void addObjectReference(SectionIndexKey key, const SafePointable *obj)
Definition: SafePointer.cc:306
assert
#define assert(condition)
Definition: Application.hh:86
TPEF::SectionWriter::registerSectionWriter
static void registerSectionWriter(const SectionWriter *sWriter)
Definition: SectionWriter.cc:148
TPEF::ReferenceManager::SafePointer::sectionKeyFor
static SectionKey sectionKeyFor(const SafePointable *obj)
Definition: SafePointer.cc:408
TPEF::FileOffset
Word FileOffset
Type for storing absolute file offsets.
Definition: TPEFBaseType.hh:52
TPEF::SectionOffset
Word SectionOffset
Type for storing offsets relative to a given base offset value.
Definition: TPEFBaseType.hh:49
TPEF::SectionSizeReplacer::setSize
static void setSize(const SafePointable *obj, Word size)
Definition: SectionSizeReplacer.cc:100
TPEF::Section::ST_STRTAB
@ ST_STRTAB
String table.
Definition: Section.hh:71
NotChunkable
Definition: Exception.hh:353
TPEF::TPEFSectionWriter::TPEFSectionWriter
TPEFSectionWriter()
Definition: TPEFSectionWriter.cc:63