e57::ImageFileImpl Class Reference

#include <ImageFileImpl.h>

Public Member Functions

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

Friends

class BlobNodeImpl
 
class CompressedVectorReaderImpl
 
class CompressedVectorWriterImpl
 
class E57XmlParser
 Diagnostic functions: More...
 

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.

◆ ~ImageFileImpl()

e57::ImageFileImpl::~ImageFileImpl ( )

Try to cancel if not already closed, but don't allow any exceptions to propagate 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.

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

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?

◆ 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.

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

Referenced by DraftGui.DraftToolBar::finish(), DraftGui.DraftToolBar::offUi(), DraftGui.DraftToolBar::pointUi(), and ~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

References e57::E57_ERROR_BAD_PATH_NAME, 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

References e57::CheckedFile::physicalToLogical(), root(), 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

References e57::E57_ERROR_BAD_API_ARGUMENT, fileName(), e57::CheckedFile::physicalToLogical(), e57::CheckedFile::ReadOnly, root(), e57::CheckedFile::WriteCreate, e57::E57FileHeader::xmlLogicalLength, and e57::E57FileHeader::xmlPhysicalOffset.

◆ decrReaderCount()

void e57::ImageFileImpl::decrReaderCount ( )

◆ decrWriterCount()

void e57::ImageFileImpl::decrWriterCount ( )

◆ 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?

References e57::E57_ERROR_BAD_PATH_NAME.

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

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

◆ extensionsCount()

size_t e57::ImageFileImpl::extensionsCount ( ) const

◆ extensionsLookupPrefix()

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

Linear search for matching prefix

Referenced by checkElementNameLegal(), and extensionsAdd().

◆ extensionsLookupUri()

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

Linear search for matching URI

Referenced by extensionsAdd().

◆ extensionsPrefix()

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

◆ extensionsUri()

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

◆ file()

◆ fileName()

ustring e57::ImageFileImpl::fileName ( ) const

Referenced by construct2().

◆ incrReaderCount()

void e57::ImageFileImpl::incrReaderCount ( )

◆ incrWriterCount()

void e57::ImageFileImpl::incrWriterCount ( )

◆ 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

References elementNameParse().

◆ isElementNameLegal()

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

Throws if elementName bad

If get here, the name was good

References checkElementNameLegal().

Referenced by pathNameParse().

◆ isOpen()

bool e57::ImageFileImpl::isOpen ( ) const

◆ isPathNameLegal()

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

Throws if pathName bad

If get here, the name was good

References pathNameCheckWellFormed().

◆ isWriter()

bool e57::ImageFileImpl::isWriter ( ) const

◆ pathNameCheckWellFormed()

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

no checkImageFileOpen(FILE, LINE, FUNCTION)

Just call pathNameParse() which throws if not well formed

References 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

References e57::E57_ERROR_BAD_PATH_NAME, and isElementNameLegal().

Referenced by pathNameCheckWellFormed().

◆ pathNameUnparse()

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

◆ readerCount()

int e57::ImageFileImpl::readerCount ( ) const

◆ root()

◆ writerCount()

int e57::ImageFileImpl::writerCount ( ) const

Friends And Related Function Documentation

◆ BlobNodeImpl

friend class BlobNodeImpl
friend

◆ CompressedVectorReaderImpl

◆ CompressedVectorWriterImpl

◆ E57XmlParser

friend class E57XmlParser
friend

Diagnostic functions:


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