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

#include <ImageFileImpl.h>

Inheritance diagram for e57::ImageFileImpl:
Collaboration diagram for e57::ImageFileImpl:

Public Member Functions

 ImageFileImpl (ReadChecksumPolicy policy)
 
void construct2 (const ustring &fileName, const ustring &mode)
 
void construct2 (const char *input, const uint64_t size)
 
std::shared_ptr< StructureNodeImplroot ()
 
void close ()
 
void cancel ()
 
bool isOpen () const
 
bool isWriter () const
 
int writerCount () const
 
int readerCount () const
 
 ~ImageFileImpl ()
 
uint64_t allocateSpace (uint64_t byteCount, bool doExtendNow)
 
CheckedFilefile () const
 
ustring fileName () const
 
void extensionsAdd (const ustring &prefix, const ustring &uri)
 Manipulate registered extensions in the file. More...
 
bool extensionsLookupPrefix (const ustring &prefix, ustring &uri) const
 
bool extensionsLookupUri (const ustring &uri, ustring &prefix) const
 
size_t extensionsCount () const
 
ustring extensionsPrefix (const size_t index) const
 
ustring extensionsUri (const size_t index) const
 
bool isElementNameExtended (const ustring &elementName)
 Utility functions: More...
 
bool isElementNameLegal (const ustring &elementName, bool allowNumber=true)
 
bool isPathNameLegal (const ustring &pathName)
 
void checkElementNameLegal (const ustring &elementName, bool allowNumber=true)
 
void elementNameParse (const ustring &elementName, ustring &prefix, ustring &localPart, bool allowNumber=true)
 
void pathNameCheckWellFormed (const ustring &pathName)
 
void pathNameParse (const ustring &pathName, bool &isRelative, StringList &fields)
 
ustring pathNameUnparse (bool isRelative, const StringList &fields)
 
unsigned bitsNeeded (int64_t minimum, int64_t maximum)
 
void incrWriterCount ()
 
void decrWriterCount ()
 
void incrReaderCount ()
 
void decrReaderCount ()
 
void dump (int indent=0, std::ostream &os=std::cout) const
 Diagnostic functions: More...
 

Detailed Description

Definition at line 41 of file ImageFileImpl.h.

Constructor & Destructor Documentation

◆ ImageFileImpl()

e57::ImageFileImpl::ImageFileImpl ( ReadChecksumPolicy  policy)

First phase of construction, can't do much until have the ImageFile object. See ImageFileImpl::construct2() for second phase.

Definition at line 77 of file ImageFileImpl.cpp.

◆ ~ImageFileImpl()

e57::ImageFileImpl::~ImageFileImpl ( )

Try to cancel if not already closed, but don't allow any exceptions to propogate to caller (because in dtor). If writing, this will unlink the file, so make sure call ImageFileImpl::close explicitly before dtor runs.

Just in case cancel failed without freeing file_, do free here.

Definition at line 392 of file ImageFileImpl.cpp.

References cancel().

Member Function Documentation

◆ allocateSpace()

uint64_t e57::ImageFileImpl::allocateSpace ( uint64_t  byteCount,
bool  doExtendNow 
)

Reserve space at end of file

If caller won't write to file immediately, it should request that the file be extended with zeros here

Definition at line 410 of file ImageFileImpl.cpp.

References e57::CheckedFile::extend().

◆ bitsNeeded()

unsigned e57::ImageFileImpl::bitsNeeded ( int64_t  minimum,
int64_t  maximum 
)

Relatively quick way to compute ceil(log2(maximum - minimum + 1))); Uses only integer operations and is machine independent (no assembly code). Find the bit position of the first 1 (from left) in the binary form of stateCountMinus1. ??? move to E57Utility?

Definition at line 888 of file ImageFileImpl.cpp.

◆ cancel()

void e57::ImageFileImpl::cancel ( )

If file already closed, have nothing to do

Close the file and ulink (delete) it. It is legal to cancel a read file, but file isn't deleted.

Definition at line 349 of file ImageFileImpl.cpp.

References e57::CheckedFile::close(), and e57::CheckedFile::unlink().

Referenced by ~ImageFileImpl().

◆ checkElementNameLegal()

void e57::ImageFileImpl::checkElementNameLegal ( const ustring elementName,
bool  allowNumber = true 
)

no checkImageFileOpen(FILE, LINE, FUNCTION)

Throws if bad elementName

If has prefix, it must be registered

Definition at line 592 of file ImageFileImpl.cpp.

References e57::E57_ERROR_BAD_PATH_NAME, E57_EXCEPTION2, elementNameParse(), and extensionsLookupPrefix().

Referenced by isElementNameLegal().

◆ close()

◆ construct2() [1/2]

void e57::ImageFileImpl::construct2 ( const char *  input,
const uint64_t  size 
)

Second phase of construction, now we have a well-formed ImageFile object.

Get shared_ptr to this object

Open file for reading.

Create parser state, attach its event handers to the SAX2 reader

Create input source (XML section of E57 file turned into a stream).

Do the parse, building up the node tree

Definition at line 184 of file ImageFileImpl.cpp.

References QtCompat::endl(), e57::E57XmlParser::init(), e57::E57XmlParser::parse(), e57::CheckedFile::physicalToLogical(), root(), size, e57::E57FileHeader::xmlLogicalLength, and e57::E57FileHeader::xmlPhysicalOffset.

◆ construct2() [2/2]

void e57::ImageFileImpl::construct2 ( const ustring fileName,
const ustring mode 
)

Second phase of construction, now we have a well-formed ImageFile object.

Get shared_ptr to this object

Open file for writing, truncate if already exists.

Open file for reading.

Create parser state, attach its event handers to the SAX2 reader

Create input source (XML section of E57 file turned into a stream).

Do the parse, building up the node tree

Definition at line 86 of file ImageFileImpl.cpp.

References e57::E57_ERROR_BAD_API_ARGUMENT, E57_EXCEPTION2, QtCompat::endl(), fileName(), e57::E57XmlParser::init(), e57::E57XmlParser::parse(), e57::CheckedFile::physicalToLogical(), e57::CheckedFile::ReadOnly, root(), e57::CheckedFile::WriteCreate, e57::E57FileHeader::xmlLogicalLength, and e57::E57FileHeader::xmlPhysicalOffset.

◆ decrReaderCount()

void e57::ImageFileImpl::decrReaderCount ( )

Definition at line 270 of file ImageFileImpl.cpp.

References e57::E57_ERROR_INTERNAL, E57_EXCEPTION2, and e57::toString().

◆ decrWriterCount()

void e57::ImageFileImpl::decrWriterCount ( )

Definition at line 252 of file ImageFileImpl.cpp.

References e57::E57_ERROR_INTERNAL, E57_EXCEPTION2, and e57::toString().

◆ dump()

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

Diagnostic functions:

no checkImageFileOpen(FILE, LINE, FUNCTION)

Definition at line 872 of file ImageFileImpl.cpp.

References QtCompat::endl(), extensionsCount(), extensionsPrefix(), extensionsUri(), and e57::space().

◆ elementNameParse()

void e57::ImageFileImpl::elementNameParse ( const ustring elementName,
ustring prefix,
ustring localPart,
bool  allowNumber = true 
)

no checkImageFileOpen(FILE, LINE, FUNCTION)

Empty name is bad

If allowing numeric element name, check if first char is digit

All remaining characters must be digits

If first char is ASCII (< 128), check for legality Don't test any part of a multi-byte code point sequence (c >= 128). Don't allow ':' as first char.

If each following char is ASCII (<128), check for legality Don't test any part of a multi-byte code point sequence (c >= 128).

Check if has at least one colon, try to split it into prefix & localPart

Check doesn't have two colons

Split element name at the colon ??? split before check first/subsequent char legal?

Definition at line 611 of file ImageFileImpl.cpp.

References e57::E57_ERROR_BAD_PATH_NAME, and E57_EXCEPTION2.

Referenced by checkElementNameLegal(), and isElementNameExtended().

◆ extensionsAdd()

void e57::ImageFileImpl::extensionsAdd ( const ustring prefix,
const ustring uri 
)

Manipulate registered extensions in the file.

Check to make sure that neither prefix or uri is already defined.

Append at end of list

Definition at line 438 of file ImageFileImpl.cpp.

References e57::E57_ERROR_DUPLICATE_NAMESPACE_PREFIX, e57::E57_ERROR_DUPLICATE_NAMESPACE_URI, E57_EXCEPTION2, extensionsLookupPrefix(), and extensionsLookupUri().

◆ extensionsCount()

size_t e57::ImageFileImpl::extensionsCount ( ) const

Definition at line 500 of file ImageFileImpl.cpp.

Referenced by dump().

◆ extensionsLookupPrefix()

bool e57::ImageFileImpl::extensionsLookupPrefix ( const ustring prefix,
ustring uri 
) const

Linear search for matching prefix

Definition at line 462 of file ImageFileImpl.cpp.

Referenced by checkElementNameLegal(), and extensionsAdd().

◆ extensionsLookupUri()

bool e57::ImageFileImpl::extensionsLookupUri ( const ustring uri,
ustring prefix 
) const

Linear search for matching URI

Definition at line 481 of file ImageFileImpl.cpp.

Referenced by extensionsAdd().

◆ extensionsPrefix()

ustring e57::ImageFileImpl::extensionsPrefix ( const size_t  index) const

Definition at line 507 of file ImageFileImpl.cpp.

Referenced by dump().

◆ extensionsUri()

ustring e57::ImageFileImpl::extensionsUri ( const size_t  index) const

Definition at line 514 of file ImageFileImpl.cpp.

Referenced by dump().

◆ file()

CheckedFile * e57::ImageFileImpl::file ( ) const

Definition at line 427 of file ImageFileImpl.cpp.

◆ fileName()

ustring e57::ImageFileImpl::fileName ( ) const

Definition at line 432 of file ImageFileImpl.cpp.

Referenced by construct2().

◆ incrReaderCount()

void e57::ImageFileImpl::incrReaderCount ( )

Definition at line 265 of file ImageFileImpl.cpp.

◆ incrWriterCount()

void e57::ImageFileImpl::incrWriterCount ( )

Definition at line 247 of file ImageFileImpl.cpp.

◆ isElementNameExtended()

bool e57::ImageFileImpl::isElementNameExtended ( const ustring elementName)

Utility functions:

don't checkImageFileOpen

Make sure doesn't have any "/" in it

Throws if elementName bad

If get here, the name was good, so test if found a prefix part

Definition at line 521 of file ImageFileImpl.cpp.

References elementNameParse().

◆ isElementNameLegal()

bool e57::ImageFileImpl::isElementNameLegal ( const ustring elementName,
bool  allowNumber = true 
)

Throws if elementName bad

If get here, the name was good

Definition at line 549 of file ImageFileImpl.cpp.

References checkElementNameLegal().

Referenced by pathNameParse().

◆ isOpen()

bool e57::ImageFileImpl::isOpen ( ) const

Definition at line 372 of file ImageFileImpl.cpp.

◆ isPathNameLegal()

bool e57::ImageFileImpl::isPathNameLegal ( const ustring pathName)

Throws if pathName bad

If get here, the name was good

Definition at line 571 of file ImageFileImpl.cpp.

References pathNameCheckWellFormed().

◆ isWriter()

bool e57::ImageFileImpl::isWriter ( ) const

Definition at line 377 of file ImageFileImpl.cpp.

◆ pathNameCheckWellFormed()

void e57::ImageFileImpl::pathNameCheckWellFormed ( const ustring pathName)

no checkImageFileOpen(FILE, LINE, FUNCTION)

Just call pathNameParse() which throws if not well formed

Definition at line 695 of file ImageFileImpl.cpp.

References fields, and pathNameParse().

Referenced by isPathNameLegal().

◆ pathNameParse()

void e57::ImageFileImpl::pathNameParse ( const ustring pathName,
bool &  isRelative,
StringList fields 
)

no checkImageFileOpen(FILE, LINE, FUNCTION)

Clear previous contents of fields vector

Check if absolute path

Save strings in between each forward slash '/' Don't ignore whitespace

Get element name from in between '/', check valid

Add to list

Handle case when pathname ends in /, e.g. "/foo/", add empty field at end of list

Skip over the slash and keep going

Empty relative path is not allowed

Definition at line 706 of file ImageFileImpl.cpp.

References e57::E57_ERROR_BAD_PATH_NAME, E57_EXCEPTION2, QtCompat::endl(), fields, and isElementNameLegal().

Referenced by pathNameCheckWellFormed().

◆ pathNameUnparse()

ustring e57::ImageFileImpl::pathNameUnparse ( bool  isRelative,
const StringList fields 
)

Definition at line 785 of file ImageFileImpl.cpp.

References fields, and cloudViewer::t::geometry::path.

◆ readerCount()

int e57::ImageFileImpl::readerCount ( ) const

Definition at line 387 of file ImageFileImpl.cpp.

◆ root()

std::shared_ptr< StructureNodeImpl > e57::ImageFileImpl::root ( void  )

Definition at line 283 of file ImageFileImpl.cpp.

Referenced by construct2().

◆ writerCount()

int e57::ImageFileImpl::writerCount ( ) const

Definition at line 382 of file ImageFileImpl.cpp.


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