#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 |
CheckedFile * | file () 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< StructureNodeImpl > | root () |
int | writerCount () const |
~ImageFileImpl () | |
Friends | |
class | BlobNodeImpl |
class | CompressedVectorReaderImpl |
class | CompressedVectorWriterImpl |
class | E57XmlParser |
Diagnostic functions: More... | |
e57::ImageFileImpl::ImageFileImpl | ( | ReadChecksumPolicy | policy | ) |
First phase of construction, can't do much until have the ImageFile object. See ImageFileImpl::construct2() for second phase.
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().
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().
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?
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().
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().
void e57::ImageFileImpl::close | ( | ) |
If file already closed, have nothing to do
Go to end of file, note physical position
Pad XML section so length is multiple of 4
Note logical length
Init header contents
Write header at beginning of file
References e57::CheckedFile::close(), e57::E57_FORMAT_MAJOR, e57::E57_FORMAT_MINOR, e57::E57FileHeader::filePhysicalLength, e57::E57FileHeader::fileSignature, e57::CheckedFile::length(), e57::CheckedFile::Logical, e57::E57FileHeader::majorVersion, e57::E57FileHeader::minorVersion, e57::E57FileHeader::pageSize, e57::CheckedFile::Physical, e57::CheckedFile::physicalPageSize, e57::CheckedFile::position(), e57::CheckedFile::seek(), e57::CheckedFile::write(), e57::E57FileHeader::xmlLogicalLength, and e57::E57FileHeader::xmlPhysicalOffset.
Referenced by femexamples.examplesgui.FemExamples::reject().
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.
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.
void e57::ImageFileImpl::decrReaderCount | ( | ) |
References e57::E57_ERROR_INTERNAL, and e57::toString().
void e57::ImageFileImpl::decrWriterCount | ( | ) |
References e57::E57_ERROR_INTERNAL, and e57::toString().
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().
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().
size_t e57::ImageFileImpl::extensionsCount | ( | ) | const |
Linear search for matching prefix
Referenced by checkElementNameLegal(), and extensionsAdd().
Linear search for matching URI
Referenced by extensionsAdd().
ustring e57::ImageFileImpl::extensionsPrefix | ( | const size_t | index | ) | const |
ustring e57::ImageFileImpl::extensionsUri | ( | const size_t | index | ) | const |
CheckedFile * e57::ImageFileImpl::file | ( | ) | const |
Referenced by exportIFCHelper.ContextCreator::createAutomaticProject(), exportIFCHelper.ContextCreator::createCustomProject(), exportIFCHelper.ContextCreator::createGeometricRepresentationContext(), exportIFCHelper.ContextCreator::createGeometricRepresentationSubContext(), exportIFCHelper.ContextCreator::createMapConversion(), exportIFCHelper.ContextCreator::createTargetCRS(), exportIFCHelper.ContextCreator::createTrueNorth(), and importIFClegacy.IfcFile::read().
ustring e57::ImageFileImpl::fileName | ( | ) | const |
Referenced by construct2().
void e57::ImageFileImpl::incrReaderCount | ( | ) |
void e57::ImageFileImpl::incrWriterCount | ( | ) |
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().
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().
bool e57::ImageFileImpl::isOpen | ( | ) | const |
bool e57::ImageFileImpl::isWriter | ( | ) | const |
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().
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().
ustring e57::ImageFileImpl::pathNameUnparse | ( | bool | isRelative, |
const StringList & | fields | ||
) |
int e57::ImageFileImpl::readerCount | ( | ) | const |
std::shared_ptr< StructureNodeImpl > e57::ImageFileImpl::root | ( | ) |
int e57::ImageFileImpl::writerCount | ( | ) | const |
|
friend |
|
friend |
|
friend |
|
friend |
Diagnostic functions: