![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
#include <ImageFileImpl.h>


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< StructureNodeImpl > | root () |
| 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) |
| CheckedFile * | file () 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... | |
Definition at line 41 of file ImageFileImpl.h.
| 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.
| 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().
| 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().
| 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.
| 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().
| 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().
| 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
Definition at line 290 of file ImageFileImpl.cpp.
References e57::CheckedFile::close(), e57::E57FileHeader::dump(), 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.
| 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.
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.
| void e57::ImageFileImpl::decrReaderCount | ( | ) |
Definition at line 270 of file ImageFileImpl.cpp.
References e57::E57_ERROR_INTERNAL, E57_EXCEPTION2, and e57::toString().
| void e57::ImageFileImpl::decrWriterCount | ( | ) |
Definition at line 252 of file ImageFileImpl.cpp.
References e57::E57_ERROR_INTERNAL, E57_EXCEPTION2, and e57::toString().
| 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().
| 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().
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().
| size_t e57::ImageFileImpl::extensionsCount | ( | ) | const |
Definition at line 500 of file ImageFileImpl.cpp.
Referenced by dump().
Linear search for matching prefix
Definition at line 462 of file ImageFileImpl.cpp.
Referenced by checkElementNameLegal(), and extensionsAdd().
Linear search for matching URI
Definition at line 481 of file ImageFileImpl.cpp.
Referenced by extensionsAdd().
| ustring e57::ImageFileImpl::extensionsPrefix | ( | const size_t | index | ) | const |
Definition at line 507 of file ImageFileImpl.cpp.
Referenced by dump().
| ustring e57::ImageFileImpl::extensionsUri | ( | const size_t | index | ) | const |
Definition at line 514 of file ImageFileImpl.cpp.
Referenced by dump().
| CheckedFile * e57::ImageFileImpl::file | ( | ) | const |
Definition at line 427 of file ImageFileImpl.cpp.
| ustring e57::ImageFileImpl::fileName | ( | ) | const |
Definition at line 432 of file ImageFileImpl.cpp.
Referenced by construct2().
| void e57::ImageFileImpl::incrReaderCount | ( | ) |
Definition at line 265 of file ImageFileImpl.cpp.
| void e57::ImageFileImpl::incrWriterCount | ( | ) |
Definition at line 247 of file ImageFileImpl.cpp.
| 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().
| 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().
| bool e57::ImageFileImpl::isOpen | ( | ) | const |
Definition at line 372 of file ImageFileImpl.cpp.
| 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().
| bool e57::ImageFileImpl::isWriter | ( | ) | const |
Definition at line 377 of file ImageFileImpl.cpp.
| 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().
| 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().
| ustring e57::ImageFileImpl::pathNameUnparse | ( | bool | isRelative, |
| const StringList & | fields | ||
| ) |
Definition at line 785 of file ImageFileImpl.cpp.
References fields, and cloudViewer::t::geometry::path.
| int e57::ImageFileImpl::readerCount | ( | ) | const |
Definition at line 387 of file ImageFileImpl.cpp.
| std::shared_ptr< StructureNodeImpl > e57::ImageFileImpl::root | ( | void | ) |
Definition at line 283 of file ImageFileImpl.cpp.
Referenced by construct2().
| int e57::ImageFileImpl::writerCount | ( | ) | const |
Definition at line 382 of file ImageFileImpl.cpp.