IOFormat 1.12.0
Loading...
Searching...
No Matches
ioformat Namespace Reference

Global namespace which contains all methods to encode/decode data from/into different resources (files, streams...) and some other helper classes and methods. More...

Classes

class  DecodingError
 
class  EncodingError
 
class  ExtractorPlugin
 Extractor plugin interface. More...
 
class  FeiMetadataHelper
 
class  FormatPlugin
 Plugin class for format encoding/decoding. More...
 
class  GeneralOptions
 A collection of general options. More...
 
class  Logger
 
class  OptionMap
 A map of heterogeneous options. More...
 
class  Plugin
 Base class for all plugins. More...
 
struct  PluginVersion
 Hold information about a plugin's version. More...
 
class  ProtocolPlugin
 ProtocolPlugin is an interface for plugins that provide access to data using a specific protocol. More...
 
class  StackReader
 
class  StackWriter
 
class  UnsupportedFormat
 
class  UnsupportedOperation
 
struct  VersionInfo
 
class  Versioning
 
class  WriterPlugin
 Writer plugin interface. More...
 

Functions

IOFORMAT_API bool init ()
 
IOFORMAT_API std::shared_ptr< iolink::View > openView (const std::string &pathFile)
 
IOFORMAT_API std::shared_ptr< iolink::View > openView (const std::string &path, const std::string &format)
 
IOFORMAT_API std::shared_ptr< iolink::View > openView (const iolink::Uri &uri)
 
IOFORMAT_API std::shared_ptr< iolink::View > openViewFromUri (const std::string &uri, const GeneralOptions &options={})
 
IOFORMAT_API std::shared_ptr< iolink::View > openView (const iolink::Uri &uri, const std::string &format)
 
IOFORMAT_API std::shared_ptr< iolink::View > openViewFromUri (const std::string &uri, const std::string &format, const GeneralOptions &options={})
 
IOFORMAT_API std::shared_ptr< iolink::ImageView > readImageFromUri (const std::string &uri, const GeneralOptions &options={})
 
IOFORMAT_API std::shared_ptr< iolink::View > openView (std::shared_ptr< iolink::DataAccess > storage, const std::string &format)
 
IOFORMAT_API std::shared_ptr< iolink::Writer > openWriter (std::shared_ptr< iolink::View > view, const std::string &pathFile)
 
IOFORMAT_API std::shared_ptr< iolink::Writer > openWriter (std::shared_ptr< iolink::View > view, std::shared_ptr< iolink::DataAccess > dst, const std::string &format)
 
IOFORMAT_API std::shared_ptr< iolink::Writer > openWriter (std::shared_ptr< iolink::View > view, std::shared_ptr< iolink::DataAccess > dst, const std::string &format, const std::string &plugin)
 
IOFORMAT_API void writeView (std::shared_ptr< iolink::View > view, const std::string &pathFile)
 
IOFORMAT_API void writeView (std::shared_ptr< iolink::View > view, std::shared_ptr< iolink::DataAccess > dst, const std::string &format)
 
IOFORMAT_API std::string formatFromExtension (const std::string &extension)
 
IOFORMAT_API std::shared_ptr< iolink::View > openView (const std::string &src, const std::string &format, const GeneralOptions &options)
 Open a view from a source path.
 
IOFORMAT_API std::shared_ptr< iolink::View > openView (const std::string &src, const GeneralOptions &options)
 Open a view from a source path.
 
IOFORMAT_API std::shared_ptr< iolink::View > openView (std::shared_ptr< iolink::StreamAccess > src, const std::string &format, const GeneralOptions &options)
 Open a view from a stream.
 
IOFORMAT_API std::shared_ptr< iolink::View > openView (std::shared_ptr< iolink::RandomAccess > src, const std::string &format, const GeneralOptions &options)
 Open a view from a random access storage.
 
IOFORMAT_API std::shared_ptr< iolink::ImageView > readImage (const std::string &src, const GeneralOptions &options)
 Read an image from a source path and store it in CPU memory.
 
IOFORMAT_API std::shared_ptr< iolink::ImageView > readImage (const std::string &pathFile)
 
IOFORMAT_API std::shared_ptr< iolink::Writer > openWriter (std::shared_ptr< iolink::View > src, const std::string &dst, const std::string &format, const GeneralOptions &options)
 Open a writer to a destination path.
 
IOFORMAT_API std::shared_ptr< iolink::Writer > openWriter (std::shared_ptr< iolink::View > src, const std::string &dst, const GeneralOptions &options)
 Open a writer to a destination path.
 
IOFORMAT_API std::shared_ptr< iolink::Writer > openWriter (std::shared_ptr< iolink::View > src, std::shared_ptr< iolink::StreamAccess > dst, const std::string &format, const GeneralOptions &options)
 Open a writer to a destination stream.
 
IOFORMAT_API void writeView (std::shared_ptr< iolink::View > src, const std::string &dst, const std::string &format, const GeneralOptions &options)
 Write a view to a destination path.
 
IOFORMAT_API void writeView (std::shared_ptr< iolink::View > src, const std::string &dst, const GeneralOptions &options)
 Write a view to a destination path.
 
IOFORMAT_API void writeView (std::shared_ptr< iolink::View > src, const std::string &dst, const std::string &format)
 Write a view to a destination path.
 
IOFORMAT_API void writeViewToUri (std::shared_ptr< iolink::View > src, const std::string &dst, const GeneralOptions &options={})
 Write a view into a destination URI. Scheme is used to determine the protocol to use.
 
IOFORMAT_API void writeViewToUri (std::shared_ptr< iolink::View > src, const std::string &dst, const std::string &format, const GeneralOptions &options={})
 Write a view into a destination URI. Scheme is used to determine the protocol to use.
 
IOFORMAT_API void writeView (std::shared_ptr< iolink::View > src, std::shared_ptr< iolink::StreamAccess > dst, const std::string &format, const GeneralOptions &options)
 Write a view into a destination stream.
 
IOFORMAT_API void writeView (std::shared_ptr< iolink::View > src, std::shared_ptr< iolink::StreamAccess > dst, const std::string &format)
 Write a view into a destination stream.
 
IOFORMAT_API void addCredentials (const std::string &host, const std::string &user, const std::string &password)
 Add credentials for a given host.
 

Detailed Description

Global namespace which contains all methods to encode/decode data from/into different resources (files, streams...) and some other helper classes and methods.

Function Documentation

◆ addCredentials()

IOFORMAT_API void ioformat::addCredentials ( const std::string &  host,
const std::string &  user,
const std::string &  password 
)

Add credentials for a given host.

If credentials were already added for the host, they will be replaced by the new ones.

Parameters
hostThe host to add credentials for (the scheme must be included to determine the protocol).
userThe user to use for authentication to given host
passwordThe password to use for authentication to given host with given user
Exceptions
Errorif the credentials cannot be assigned to a supported protocol
InvalidArgumentif the scheme is not present in host address

◆ formatFromExtension()

IOFORMAT_API std::string ioformat::formatFromExtension ( const std::string &  extension)

Helper to retrieve a format from an extension.

Extension are case insensitive, so for example "png" and "PNG" are the same for this function, and will return the same format.

Parameters
extensionstring which contains the extension to identify (without dot)
Returns
a string containing the format identifier corresponding to this extension

◆ init()

IOFORMAT_API bool ioformat::init ( )

Force IOFormat initialization. If not called, it will be initialized at the first call of any following methods. This method allows you to force the loading of all the IOFormat plugins. It may take some time, depending on the number of plugins to load.

Returns
true if at least one plugin was correctly loaded, false otherwise

◆ openView() [1/9]

IOFORMAT_API std::shared_ptr< iolink::View > ioformat::openView ( const iolink::Uri &  uri)

Access to data from Uniform Resource Identifier, using the extension of the path to determine format

Exceptions
iolink::Error
Deprecated:
Deprecated in 1.12, will be dropped in 2.0, you should use ioformat::openViewFromUri(const std::string & uri) method instead.

◆ openView() [2/9]

IOFORMAT_API std::shared_ptr< iolink::View > ioformat::openView ( const iolink::Uri &  uri,
const std::string &  format 
)

Access to data from Uniform Resource Identifier, using the given format to decode it

Exceptions
iolink::Error
Deprecated:
Deprecated in 1.12, will be dropped in 2.0, you should use ioformat::openViewFromUri(const std::string & uri, const std::string& format) method instead.

◆ openView() [3/9]

IOFORMAT_API std::shared_ptr< iolink::View > ioformat::openView ( const std::string &  path,
const std::string &  format 
)

Open a View on the file at the given path, forcing to a specific format.

Parameters
pathThe path to the file
formatThe format to use to read the file
Exceptions
UnsupportedFormatWhen the extractor selected according to the format cannot read the file.

◆ openView() [4/9]

IOFORMAT_API std::shared_ptr< iolink::View > ioformat::openView ( const std::string &  pathFile)

Access to data from given file, using the extension of the file to determine format

Exceptions
iolink::Error
iolink::InvalidArgument
ioformat::UnsupportedFormat

◆ openView() [5/9]

IOFORMAT_API std::shared_ptr< iolink::View > ioformat::openView ( const std::string &  src,
const GeneralOptions options 
)

Open a view from a source path.

The format will be inferred from the path's extension.

Parameters
srcThe path to the source file.
optionsThe options to use to read the file.
Returns
A view on the opened file.
Exceptions
iolink::ErrorWhen the file cannot be opened.

◆ openView() [6/9]

IOFORMAT_API std::shared_ptr< iolink::View > ioformat::openView ( const std::string &  src,
const std::string &  format,
const GeneralOptions options 
)

Open a view from a source path.

Parameters
srcThe path to the source file.
formatThe format to use to read the file.
optionsThe options to use to read the file.
Returns
A view on the opened file.
Exceptions
iolink::ErrorWhen the file cannot be opened.

◆ openView() [7/9]

IOFORMAT_API std::shared_ptr< iolink::View > ioformat::openView ( std::shared_ptr< iolink::DataAccess >  storage,
const std::string &  format 
)

Access to data from given storage, using the given format to decode it

Parameters
storageinput storage containing the data to decode with given format
formatfile format to apply on given stream to decode
Exceptions
iolink::Error
iolink::InvalidArgument
ioformat::UnsupportedFormat

◆ openView() [8/9]

IOFORMAT_API std::shared_ptr< iolink::View > ioformat::openView ( std::shared_ptr< iolink::RandomAccess >  src,
const std::string &  format,
const GeneralOptions options 
)

Open a view from a random access storage.

Parameters
srcThe random access storage to read from.
formatThe format to use to read the storage.
optionsThe options to use to read the storage.
Returns
A view on the opened storage.
Exceptions
iolink::ErrorWhen the decoding of the view fails.

◆ openView() [9/9]

IOFORMAT_API std::shared_ptr< iolink::View > ioformat::openView ( std::shared_ptr< iolink::StreamAccess >  src,
const std::string &  format,
const GeneralOptions options 
)

Open a view from a stream.

Parameters
srcThe stream to read from.
formatThe format to use to read the stream.
optionsThe options to use to read the stream.
Returns
A view on the opened stream.
Exceptions
iolink::ErrorWhen the decoding of the view fails.

◆ openViewFromUri() [1/2]

IOFORMAT_API std::shared_ptr< iolink::View > ioformat::openViewFromUri ( const std::string &  uri,
const GeneralOptions options = {} 
)

Access to data from Uniform Resource Identifier, using the extension of the path to determine format, and the scheme from the URI to determine the protocol to use.

Parameters
uriThe URI to open (scheme is mandatory to select the appropriate protocol plugin)
optionsGeneral options to use when opening the view
Exceptions
iolink::InvalidArgumentif the URI does not contain any scheme
iolink::InvalidArgumentif the URI is not valid
iolink::InvalidArgumentif the URI does not contain a valid extension
iolink::Errorif protocol plugin is not found
iolink::Errorif the format plugin is not found or cannot handle the file
Remarks
See plugin chapter in IOFormat user guide for more details about the protocols and formats supported.

◆ openViewFromUri() [2/2]

IOFORMAT_API std::shared_ptr< iolink::View > ioformat::openViewFromUri ( const std::string &  uri,
const std::string &  format,
const GeneralOptions options = {} 
)

Access to data from Uniform Resource Identifier, using the given format to decode it, and the scheme from the URI to determine the protocol to use.

Parameters
uriThe URI to open (scheme is mandatory to select the appropriate protocol plugin)
formatThe format to use to decode the data
optionsGeneral options to use when opening the view
Exceptions
iolink::InvalidArgumentif the URI does not contain any scheme
iolink::InvalidArgumentif the URI is not valid
iolink::Errorif protocol plugin is not found
iolink::Errorif the format plugin is not found or cannot handle the file
Remarks
See plugin chapter in IOFormat user guide for more details about the protocols and formats supported.

◆ openWriter() [1/6]

IOFORMAT_API std::shared_ptr< iolink::Writer > ioformat::openWriter ( std::shared_ptr< iolink::View >  src,
const std::string &  dst,
const GeneralOptions options 
)

Open a writer to a destination path.

The format will be inferred from the path's extension.

Parameters
srcThe view to write.
dstThe path to the destination file.
optionsThe options to use to write the file.
Returns
A writer ready to write the source view to the destination file.
Exceptions
iolink::ErrorWhen the source view cannot be written into the destination file.

◆ openWriter() [2/6]

IOFORMAT_API std::shared_ptr< iolink::Writer > ioformat::openWriter ( std::shared_ptr< iolink::View >  src,
const std::string &  dst,
const std::string &  format,
const GeneralOptions options 
)

Open a writer to a destination path.

Parameters
srcThe view to write.
dstThe path to the destination file.
formatThe format to use to write the file.
optionsThe options to use to write the file.
Returns
A writer ready to write the source view to the destination file.
Exceptions
iolink::ErrorWhen the source view cannot be written into the destination file.

◆ openWriter() [3/6]

IOFORMAT_API std::shared_ptr< iolink::Writer > ioformat::openWriter ( std::shared_ptr< iolink::View >  src,
std::shared_ptr< iolink::StreamAccess >  dst,
const std::string &  format,
const GeneralOptions options 
)

Open a writer to a destination stream.

Parameters
srcThe view to write.
dstThe stream to write into.
formatThe format to use to write the stream.
optionsThe options to use to write into the stream.
Returns
A writer ready to write the source view to the destination stream.
Exceptions
iolink::ErrorWhen the source view cannot be written into the destination stream.

◆ openWriter() [4/6]

IOFORMAT_API std::shared_ptr< iolink::Writer > ioformat::openWriter ( std::shared_ptr< iolink::View >  view,
const std::string &  pathFile 
)

Open a writer used to write an image view into a file.

Parameters
viewThe view that will be written
pathFilea path to the output file.
Returns
A writer ready to write the image into the file.

◆ openWriter() [5/6]

IOFORMAT_API std::shared_ptr< iolink::Writer > ioformat::openWriter ( std::shared_ptr< iolink::View >  view,
std::shared_ptr< iolink::DataAccess >  dst,
const std::string &  format 
)

Open a writer used to write an image view into an output stream.

Parameters
viewThe view that will be written
dstThe output stream where the encoded data will be written.
formatThe format to use to encode the image.
Returns
A writer ready to write the image into the output stream.

◆ openWriter() [6/6]

IOFORMAT_API std::shared_ptr< iolink::Writer > ioformat::openWriter ( std::shared_ptr< iolink::View >  view,
std::shared_ptr< iolink::DataAccess >  dst,
const std::string &  format,
const std::string &  plugin 
)

Open a writer used to write an image view into an output stream.

Parameters
viewThe view that will be written
dstThe output stream where the encoded data will be written.
formatThe format to use to encode the image.
pluginThe specific plugin to use.
Returns
A writer ready to write the image into the output stream.

◆ readImage() [1/2]

IOFORMAT_API std::shared_ptr< iolink::ImageView > ioformat::readImage ( const std::string &  pathFile)

Access to data from given file, using the extension of the file to determine format. Image is fully loaded in memory. Limitation:

  • If file contains more than one image (like an image and its thumbnail), this method will only load first read frame.
  • If file contains a LOD image, resolution-0 image is read
  • If data is not an image or is not readable, an UnsupportedFormat exception is thrown
    Exceptions
    iolink::ErrorIf an error occurs during the reading.
    ioformat::UnsupportedFormatIf the file is not an image.

◆ readImage() [2/2]

IOFORMAT_API std::shared_ptr< iolink::ImageView > ioformat::readImage ( const std::string &  src,
const GeneralOptions options 
)

Read an image from a source path and store it in CPU memory.

Parameters
srcThe path to the source file.
optionsThe options to use to read the file.
Returns
An image view in memory holding the data from the image in the source path.
Exceptions
iolink::ErrorWhen the image cannot be read.
ioformat::UnsupportedFormatWhen the file do not contain an image.

◆ readImageFromUri()

IOFORMAT_API std::shared_ptr< iolink::ImageView > ioformat::readImageFromUri ( const std::string &  uri,
const GeneralOptions options = {} 
)

Access to image from Uniform Resource Identifier. The scheme from the URI is used to determine the protocol to use.

Parameters
uriThe URI to open (scheme is mandatory to select the appropriate protocol plugin)
optionsGeneral options to use when opening the view
Exceptions
iolink::InvalidArgumentif the URI does not contain any scheme
iolink::InvalidArgumentif the URI is not valid
iolink::InvalidArgumentif the URI does not contain a valid extension
iolink::Errorif protocol plugin is not found
iolink::Errorif the format plugin is not found or cannot handle the file
Remarks
See plugin chapter in IOFormat user guide for more details about the protocols and formats supported.

◆ writeView() [1/7]

IOFORMAT_API void ioformat::writeView ( std::shared_ptr< iolink::View >  src,
const std::string &  dst,
const GeneralOptions options 
)

Write a view to a destination path.

The format will be inferred from the path's extension.

Parameters
srcThe view to write.
dstThe path to the destination file.
optionsThe options to use to write the file.
Exceptions
iolink::ErrorWhen the source view cannot be written into the destination file.

◆ writeView() [2/7]

IOFORMAT_API void ioformat::writeView ( std::shared_ptr< iolink::View >  src,
const std::string &  dst,
const std::string &  format 
)

Write a view to a destination path.

Parameters
srcThe view to write.
dstThe path to the destination file.
formatThe format to use to write the file.
Exceptions
iolink::ErrorWhen the source view cannot be written into the destination file.

◆ writeView() [3/7]

IOFORMAT_API void ioformat::writeView ( std::shared_ptr< iolink::View >  src,
const std::string &  dst,
const std::string &  format,
const GeneralOptions options 
)

Write a view to a destination path.

Parameters
srcThe view to write.
dstThe path to the destination file.
formatThe format to use to write the file.
optionsThe options to use to write the file.
Exceptions
iolink::ErrorWhen the source view cannot be written into the destination file.

◆ writeView() [4/7]

IOFORMAT_API void ioformat::writeView ( std::shared_ptr< iolink::View >  src,
std::shared_ptr< iolink::StreamAccess >  dst,
const std::string &  format 
)

Write a view into a destination stream.

Parameters
srcThe view to write.
dstThe stream to write into.
formatThe format to use to write into the stream.
Exceptions
iolink::ErrorWhen the source view cannot be written into the destination stream.

◆ writeView() [5/7]

IOFORMAT_API void ioformat::writeView ( std::shared_ptr< iolink::View >  src,
std::shared_ptr< iolink::StreamAccess >  dst,
const std::string &  format,
const GeneralOptions options 
)

Write a view into a destination stream.

Parameters
srcThe view to write.
dstThe stream to write into.
formatThe format to use to write into the stream.
optionsThe options to use to write the stream.
Exceptions
iolink::ErrorWhen the source view cannot be written into the destination stream.

◆ writeView() [6/7]

IOFORMAT_API void ioformat::writeView ( std::shared_ptr< iolink::View >  view,
const std::string &  pathFile 
)

Save a view into a file.

Parameters
viewThe view to save
pathFileThe path of the file where to save the image
Exceptions
iolink::ErrorWhen the image cannot be written

◆ writeView() [7/7]

IOFORMAT_API void ioformat::writeView ( std::shared_ptr< iolink::View >  view,
std::shared_ptr< iolink::DataAccess >  dst,
const std::string &  format 
)

Save a view into a storage.

Parameters
viewThe view to save
dstThe storage where to save the image
formatThe format in which the image will be encoded
Exceptions
iolink::ErrorWhen the image cannot be written

◆ writeViewToUri() [1/2]

IOFORMAT_API void ioformat::writeViewToUri ( std::shared_ptr< iolink::View >  src,
const std::string &  dst,
const GeneralOptions options = {} 
)

Write a view into a destination URI. Scheme is used to determine the protocol to use.

Parameters
srcThe view to write.
dstThe URI to write into (the scheme must be included to determine the protocol).
optionsThe options to use to write the data.
Remarks
See plugin chapter in IOFormat user guide for more details about the protocols and formats supported.
Exceptions
iolink::InvalidArgumentif the URI does not contain any scheme
iolink::InvalidArgumentif the URI is not valid
iolink::InvalidArgumentif the URI does not contain a valid extension
iolink::ErrorWhen the source view cannot be written into the destination URI.

◆ writeViewToUri() [2/2]

IOFORMAT_API void ioformat::writeViewToUri ( std::shared_ptr< iolink::View >  src,
const std::string &  dst,
const std::string &  format,
const GeneralOptions options = {} 
)

Write a view into a destination URI. Scheme is used to determine the protocol to use.

Parameters
srcThe view to write.
dstThe URI to write into (the scheme must be included to determine the protocol).
formatThe format to use to encode the view.
optionsThe options to use to write the data.
Remarks
See plugin chapter in IOFormat user guide for more details about the protocols and formats supported.
Exceptions
iolink::InvalidArgumentif the URI does not contain any scheme
iolink::InvalidArgumentif the URI is not valid
iolink::ErrorWhen the source view cannot be written into the destination URI.