Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extensionsLookupPrefix overload for more concise user code #161

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/E57Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ protected:

// Manipulate registered extensions in the file
void extensionsAdd( const ustring &prefix, const ustring &uri );
bool extensionsLookupPrefix( const ustring &prefix ) const;
bool extensionsLookupPrefix( const ustring &prefix, ustring &uri ) const;
bool extensionsLookupUri( const ustring &uri, ustring &prefix ) const;
size_t extensionsCount() const;
Expand Down
20 changes: 20 additions & 0 deletions src/ImageFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,26 @@ void ImageFile::extensionsAdd( const ustring &prefix, const ustring &uri )
impl_->extensionsAdd( prefix, uri );
}

/*!
@brief Look up an E57 extension prefix in the ImageFile.
@param [in] prefix The shorthand name of the extension to look up.
@details
If @a prefix = "" or @a prefix is declared in the ImageFile, then the function returns true. It is an error if @a prefix
contains an illegal character combination for E57 namespace prefixes.
@pre This ImageFile must be open (i.e. isOpen()).
@post No visible state is modified.
@return true if prefix is declared in the ImageFile.
@throw ::E57_ERROR_BAD_API_ARGUMENT
@throw ::E57_ERROR_IMAGEFILE_NOT_OPEN
@throw ::E57_ERROR_INTERNAL All objects in undocumented state
@see ImageFile::extensionsLookupUri
*/
bool ImageFile::extensionsLookupPrefix( const ustring &prefix ) const
{
ustring uri;
return impl_->extensionsLookupPrefix( prefix, uri );
}

/*!
@brief Get URI associated with an E57 extension prefix in the ImageFile.
@param [in] prefix The shorthand name of the extension to look up.
Expand Down
3 changes: 1 addition & 2 deletions src/ReaderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1136,8 +1136,7 @@ namespace e57

// E57_EXT_surface_normals
// See: http://www.libe57.org/E57_EXT_surface_normals.txt
ustring norExtUri;
if ( imf_.extensionsLookupPrefix( "nor", norExtUri ) )
if ( imf_.extensionsLookupPrefix( "nor" ) )
{
data3DHeader.pointFields.normalXField = proto.isDefined( "nor:normalX" );
data3DHeader.pointFields.normalYField = proto.isDefined( "nor:normalY" );
Expand Down
6 changes: 2 additions & 4 deletions src/WriterImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -941,8 +941,7 @@ namespace e57
data3DHeader.pointFields.normalZField )
{
// make sure we declare the extension before using the fields with prefix
ustring norExtUri;
if ( !imf_.extensionsLookupPrefix( "nor", norExtUri ) )
if ( !imf_.extensionsLookupPrefix( "nor" ) )
{
imf_.extensionsAdd( "nor", "http://www.libe57.org/E57_EXT_surface_normals.txt" );
}
Expand Down Expand Up @@ -1088,8 +1087,7 @@ namespace e57
}

// E57_EXT_surface_normals
ustring norExtUri;
if ( imf_.extensionsLookupPrefix( "nor", norExtUri ) )
if ( imf_.extensionsLookupPrefix( "nor" ) )
{
if ( proto.isDefined( "nor:normalX" ) && ( buffers.normalX != nullptr ) )
{
Expand Down