E57 Foundation API v1.1.312  Aug. 10, 2011
void extensionsAdd ( const ustring prefix,
const ustring uri 
)

Declare the use of an E57 extension in an ImageFile being written.

Parameters:
[in]prefixThe shorthand name of the extension to use in element names.
[in]uriThe Uniform Resource Identifier string to associate with the prefix in the ImageFile.

The (prefix, uri) pair is registered in the known extensions of the ImageFile. Both prefix and uri must be unique in the ImageFile. It is not legal to declare a URI associated with the default namespace (prefix = ""). It is not an error to declare a namespace and not use it in an element name. It is an error to use a namespace prefix in an element name that is not declared beforehand.

A writer is free to "hard code" the prefix names in the element name strings that it uses (since it established the prefix declarations in the file). A reader cannot assume that any given prefix is always mapped to the same URI or vice versa. A reader might check an ImageFile, and if the prefixes aren't the way it likes, the reader could give up.

A better scheme would be to lookup the URI that the reader is familiar with, and store the prefix that the particular file uses in a variable. Then every time the reader needs to form a prefixed element name, it can assemble the full element name from the stored prefix variable and the constant documented base name string. This is less convenient than using a single "hard coded" string constant for an element name, but it is robust against any choice of prefix/URI combination.

See the class discussion at bottom of ImageFile page for more details about namespaces.

Precondition:
This ImageFile must be open (i.e. isOpen()).
ImageFile must have been opened in write mode (i.e. isWritable()).
prefix != ""
uri != ""
Exceptions:
E57_ERROR_BAD_API_ARGUMENT
E57_ERROR_IMAGEFILE_NOT_OPEN
E57_ERROR_FILE_IS_READ_ONLY
E57_ERROR_DUPLICATE_NAMESPACE_PREFIX
E57_ERROR_DUPLICATE_NAMESPACE_URI
E57_ERROR_INTERNALAll objects in undocumented state
See also:
Extensions.cpp example, ImageFile::extensionsCount, ImageFile::extensionsLookupPrefix, ImageFile::extensionsLookupUri
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines