ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
e57::BitpackStringEncoder Class Reference

#include <Encoder.h>

Inheritance diagram for e57::BitpackStringEncoder:
Collaboration diagram for e57::BitpackStringEncoder:

Public Member Functions

 BitpackStringEncoder (unsigned bytestreamNumber, SourceDestBuffer &sbuf, unsigned outputMaxSize)
 
uint64_t processRecords (size_t recordCount) override
 
bool registerFlushToOutput () override
 
float bitsPerRecord () override
 
void dump (int indent=0, std::ostream &os=std::cout) const override
 
- Public Member Functions inherited from e57::BitpackEncoder
unsigned sourceBufferNextIndex () override
 
uint64_t currentRecordIndex () override
 
size_t outputAvailable () const override
 
void outputRead (char *dest, const size_t byteCount) override
 number of bytes that can be read More...
 
void outputClear () override
 get data from encoder More...
 
void sourceBufferSetNew (std::vector< SourceDestBuffer > &sbufs) override
 
size_t outputGetMaxSize () override
 
void outputSetMaxSize (unsigned byteCount) override
 
- Public Member Functions inherited from e57::Encoder
virtual ~Encoder ()=default
 
unsigned bytestreamNumber () const
 

Protected Attributes

uint64_t totalBytesProcessed_
 
bool isStringActive_
 
bool prefixComplete_
 
ustring currentString_
 
size_t currentCharPosition_
 
- Protected Attributes inherited from e57::BitpackEncoder
std::shared_ptr< SourceDestBufferImplsourceBuffer_
 
std::vector< char > outBuffer_
 
size_t outBufferFirst_
 
size_t outBufferEnd_
 
size_t outBufferAlignmentSize_
 
uint64_t currentRecordIndex_
 
- Protected Attributes inherited from e57::Encoder
unsigned bytestreamNumber_
 

Additional Inherited Members

- Static Public Member Functions inherited from e57::Encoder
static std::shared_ptr< EncoderEncoderFactory (unsigned bytestreamNumber, std::shared_ptr< CompressedVectorNodeImpl > cVector, std::vector< SourceDestBuffer > &sbuf, ustring &codecPath)
 
- Protected Member Functions inherited from e57::BitpackEncoder
 BitpackEncoder (unsigned bytestreamNumber, SourceDestBuffer &sbuf, unsigned outputMaxSize, unsigned alignmentSize)
 ================ More...
 
void outBufferShiftDown ()
 
- Protected Member Functions inherited from e57::Encoder
 Encoder (unsigned bytestreamNumber)
 

Detailed Description

Definition at line 125 of file Encoder.h.

Constructor & Destructor Documentation

◆ BitpackStringEncoder()

BitpackStringEncoder::BitpackStringEncoder ( unsigned  bytestreamNumber,
SourceDestBuffer sbuf,
unsigned  outputMaxSize 
)

Definition at line 477 of file Encoder.cpp.

Member Function Documentation

◆ bitsPerRecord()

float BitpackStringEncoder::bitsPerRecord ( )
overridevirtual

Return average number of bits in strings + 8 bits for prefix

We haven't completed a record yet, so guess 100 bytes per record

Implements e57::BitpackEncoder.

Definition at line 609 of file Encoder.cpp.

References e57::BitpackEncoder::currentRecordIndex_, and totalBytesProcessed_.

◆ dump()

void BitpackStringEncoder::dump ( int  indent = 0,
std::ostream &  os = std::cout 
) const
overridevirtual

◆ processRecords()

uint64_t BitpackStringEncoder::processRecords ( size_t  recordCount)
overridevirtual

Before we add any more, try to shift current contents of outBuffer_ down to beginning of buffer.

Figure out how many bytes outBuffer can accept.

Form the starting address for next available location in outBuffer

Don't start loop unless have at least 8 bytes for worst case string length prefix

Calc the length prefix, either 1 byte or 8 bytes

We can use the short length prefix: b0=0, b7-b1=len

Double check have space

We use the long length prefix: b0=1, b63-b1=len, and store in little endian order Shift the length and set the least significant bit, b0=1.

Copy as much string as will fit in outBuffer

Check if finished string

Get next string from sourceBuffer

Update end of outBuffer

Update counts of records processed

Implements e57::BitpackEncoder.

Definition at line 484 of file Encoder.cpp.

References currentCharPosition_, e57::BitpackEncoder::currentRecordIndex_, currentString_, e57::E57_ERROR_INTERNAL, E57_EXCEPTION2, QtCompat::endl(), isStringActive_, min(), e57::BitpackEncoder::outBuffer_, e57::BitpackEncoder::outBufferEnd_, e57::BitpackEncoder::outBufferShiftDown(), prefixComplete_, e57::BitpackEncoder::sourceBuffer_, e57::toString(), and totalBytesProcessed_.

◆ registerFlushToOutput()

bool BitpackStringEncoder::registerFlushToOutput ( )
overridevirtual

Since have no registers in encoder, return success

Implements e57::BitpackEncoder.

Definition at line 603 of file Encoder.cpp.

Member Data Documentation

◆ currentCharPosition_

size_t e57::BitpackStringEncoder::currentCharPosition_
protected

Definition at line 142 of file Encoder.h.

Referenced by dump(), and processRecords().

◆ currentString_

ustring e57::BitpackStringEncoder::currentString_
protected

Definition at line 141 of file Encoder.h.

Referenced by dump(), and processRecords().

◆ isStringActive_

bool e57::BitpackStringEncoder::isStringActive_
protected

Definition at line 139 of file Encoder.h.

Referenced by dump(), and processRecords().

◆ prefixComplete_

bool e57::BitpackStringEncoder::prefixComplete_
protected

Definition at line 140 of file Encoder.h.

Referenced by dump(), and processRecords().

◆ totalBytesProcessed_

uint64_t e57::BitpackStringEncoder::totalBytesProcessed_
protected

Definition at line 138 of file Encoder.h.

Referenced by bitsPerRecord(), dump(), and processRecords().


The documentation for this class was generated from the following files: