Abstract base class for IFileFormat implementations that represent a concrete file format.
abstract class
|
FileFormat
|
implements
|
IFileFormat
|
||
base of
|
ImageFormat
|
||||
ModelFormat
|
|||||
ShapeFormat
|
Has this file format been registered?
protected
property
|
IsRegistered
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
this
file
format
has
been
registered,
false
if
not. |
See also:
RegisterCreates a new instance of FileFormat.
protected
constructor
|
FileFormat
(string name,
string description,
string type,
string mime,
bool isAny = false)
|
||
params
|
name
|
[not-empty]
|
Value for Name |
description
|
[not-empty]
|
Value for Description | |
type
|
[not-empty]
|
Value for Type | |
mime
|
Value for Mime | ||
isAny
|
Is this an automatic file format? |
Checks if the given data is equal to the identifying prefix of this file format.
[EmptyBody]
|
||||
protected
virtual
method
|
DoCanRead
(ByteBuffer data)
|
|||
type
|
bool
|
|||
params
|
data
|
The data to check for the presence of the identifying prefix. When this method is called, this buffer position and limit will have been set so that the remaining bytes cover the byte sequence to check, having a length of exactly Prefix bytes. The buffer position may be modified by this method. | ||
returns
|
true
if
data
is
equal
to
the
identifying
prefix,
false
if
data
is
not
equal
to
the
identifying
prefix.
|
Remarks:
When overriding this method, Prefix must be overridden as well.
Finds the IFileFormat that has the given name.
protected
method
|
NameFind
(string name)
|
||
type
|
IFileFormat
|
||
params
|
name
|
[not-empty]
|
The file format name. |
returns
|
The
found
file
format
or
null . |
protected
static
method
|
NotSupported
(string source,
Path path,
string name,
bool directory,
string suffix)
|
||
type
|
IOException
|
||
params
|
source
|
||
path
|
|||
name
|
|||
directory
|
|||
suffix
|
Appends this file format to the chain of the given file format.
[ThreadSafe]
|
||||
protected
method
|
Register
(FileFormat any)
|
|||
params
|
any
|
[not-null]
|
The file format chain to append to. |
Long description of this file format.
public
virtual
property
|
Description
{
get
}
|
||
type
|
string
|
||
value
|
|
The description string. | |
implements
|
IFileFormat.Description
|
The machine-readable type of this file format.
public
property
|
Mime
{
get
}
|
||
type
|
string
|
||
value
|
The
machine-readable
media
type
or
null
if
none. |
||
implements
|
IFileFormat.Mime
|
Remarks:
For
details
on
Media
Types
(aka.
MIME-type),
please
refer
to
this
webpage:
https://www.iana.org/assignments/media-types/media-types.xhtml
The file format name.
public
property
|
Name
{
get
}
|
||
type
|
string
|
||
value
|
|
The file format name. | |
implements
|
IFileFormat.Name
|
Returns the next file format.
[ThreadSafe]
|
||||
public
property
|
Next
{
get
}
|
|||
type
|
IFileFormat
|
|||
value
|
The
next
file
format
or
null . |
|||
implements
|
IFileFormat.Next
|
Remarks:
The first file format can be obtained from implementing classes. This property can be used to cycle all available file formats of the same type.
Lengths of the binary file data prefix that identifies this file format.
public
virtual
property
|
Prefix
{
get
}
|
||
type
|
int32
|
||
value
|
|
The
file
data
prefix
length,
in
bytes.
If
0 ,
there
is
no
identifying
prefix.
|
|
implements
|
IFileFormat.Prefix
|
The human-readable type of this file format (e.g. images, shapes, 3D models).
public
property
|
Type
{
get
}
|
||
type
|
string
|
||
value
|
|
The human-readable type name. | |
implements
|
IFileFormat.Type
|
Returns a registered file format by its Mime.
public
static
method
|
ForMime
(string mime)
|
||
type
|
IFileFormat
|
||
params
|
mime
|
[not-null]
|
The file image media type. |
returns
|
The
file
format
or
null
if
not
found. |
Can this file format object be used to read the given data?
public
method
|
CanRead
(ByteBuffer data)
|
||
type
|
bool
|
||
params
|
data
|
[not-null]
|
The
data
to
check.
Must
have
at
least
Prefix
remaining
bytes,
otherwise
this
method
will
always
return
false .
The
buffer
will
not
be
modified
by
this
method.
|
returns
|
true
if
the
given
data
is
prefixed
with
the
identifying
byte
sequence
of
this
file
format,
false
if
the
prefix
is
not
present.
|
||
implements
|
IFileFormat.CanRead
|
See also:
IFileFormat.PrefixCan this file format object be used to read the given path?
public
virtual
method
|
CanRead
(string suffix,
bool directory = false)
|
||
type
|
bool
|
||
params
|
suffix
|
[not-null]
|
The
lower-case
pathname
suffix
(without
'.' ).
Will
be
empty
if
the
path
does
not
have
a
pathname
suffix.
|
directory
|
Does
the
path
refer
to
a
directory
(true )
or
to
a
file
(false )?
Defaults
to
false .
|
||
returns
|
true
if
this
file
format
can
be
used,
false
if
not. |
||
implements
|
IFileFormat.CanRead
|
Returns the first file format in the chain (see Next) that can read the given data.
public
method
|
CanReadFind
(ByteBuffer data)
|
||
type
|
IFileFormat
|
||
params
|
data
|
[not-null]
|
The
data
to
check.
Must
have
at
least
Prefix
remaining
bytes,
otherwise
this
method
will
always
return
false .
The
buffer
will
not
be
modified
by
this
method.
|
returns
|
The
found
file
format
or
null . |
||
implements
|
IFileFormat.CanReadFind
|
Returns the first file format in the chain (see Next) that can read the given path.
public
virtual
method
|
CanReadFind
(string suffix,
bool directory = false)
|
||
type
|
IFileFormat
|
||
params
|
suffix
|
[not-null]
|
The
lower-case
pathname
suffix
(without
'.' ).
Will
be
empty
if
the
path
does
not
have
a
pathname
suffix.
|
directory
|
Does
the
path
refer
to
a
directory
(true )
or
to
a
file
(false )?
Defaults
to
false .
|
||
returns
|
The
found
file
format
or
null . |
||
implements
|
IFileFormat.CanReadFind
|
Can this file format object be used to write the given path?
public
virtual
method
|
CanWrite
(string suffix)
|
||
type
|
bool
|
||
params
|
suffix
|
[not-null]
|
The
lower-case
pathname
suffix
(without
'.' ).
Will
be
empty
if
the
path
does
not
have
a
pathname
suffix.
|
returns
|
true
if
this
file
format
can
be
used,
false
if
not. |
||
implements
|
IFileFormat.CanWrite
|
Returns the first file format in the chain (see Next) that can write the given path.
public
virtual
method
|
CanWriteFind
(string suffix)
|
||
type
|
IFileFormat
|
||
params
|
suffix
|
[not-null]
|
The
lower-case
pathname
suffix
(without
'.' ).
Will
be
empty
if
the
path
does
not
have
a
pathname
suffix.
|
returns
|
The
found
file
format
or
null . |
||
implements
|
IFileFormat.CanWriteFind
|
Normalizes the given MIME type.
[Pure]
|
||||
public
static
method
|
Normalize
(string mime)
|
|||
type
|
string
|
|||
params
|
mime
|
The MIME type. | ||
returns
|
The
normalized
MIME
type
of
null
iff
mime
is
empty
or
whitespace.
|
Remarks:
The given mime is converted to lower-case and all leading and trailing whitespaces are trimmed. Then, the following substitutions are performed:
This is a method that forces the compiler / linker to include this type in the resulting binary.
public
virtual
method
|
PleaseIncludeInBinaryThanks
()
|
||
implements
|
IPleaseIncludeInBinaryThanks.PleaseIncludeInBinaryThanks
|
Remarks:
Calling this stub method makes sure that all lazy constructor calls have been made.
To initialize everything, an application needs to call this method on its root module(s) (see TinmanModule), followed by a call to Initialize.
Exceptions:
[Pure]
|
||||
public
override
sealed
method
|
ToString
()
|
|||
type
|
string
|