libCZI
Reading and Writing CZI documents made easy
libCZI::StreamsFactory Class Reference

#include <libCZI_StreamsLib.h>

Classes

struct  CreateStreamInfo
 The parameters for creating an instance of a stream object. More...
 
struct  Property
 This declares a variant type (to be used with the property bag in the streams factory). More...
 
struct  StreamClassInfo
 This structure gathers information about a stream class. More...
 
class  StreamProperties
 Here the keys for the property-bag with options for creating a stream-object are gathered. More...
 
struct  StreamPropertyBagPropertyInfo
 Information about a property for the property bag when creating a stream object. More...
 

Static Public Member Functions

static const StreamPropertyBagPropertyInfoGetStreamPropertyBagPropertyInfo (int *count)
 
static void Initialize ()
 
static std::shared_ptr< libCZI::IStreamCreateStream (const CreateStreamInfo &stream_info, const std::string &file_identifier)
 
static std::shared_ptr< libCZI::IStreamCreateStream (const CreateStreamInfo &stream_info, const std::wstring &file_identifier)
 
static bool GetStreamInfoForClass (int index, StreamClassInfo &stream_info)
 
static int GetStreamClassesCount ()
 
static std::shared_ptr< libCZI::IStreamCreateDefaultStreamForFile (const char *filename)
 
static std::shared_ptr< libCZI::IStreamCreateDefaultStreamForFile (const wchar_t *filename)
 

Static Public Attributes

static const char * kStreamClassInfoProperty_CurlHttp_CaInfo
 
static const char * kStreamClassInfoProperty_CurlHttp_CaPath
 

Detailed Description

A factory object for creating streams objects. libCZI is operating on abstractions (IStream for an input stream, IOutputStream for an output stream and IInputOutputStream for and input-output-stream) for accessing the CZI-data. In this class factory we gather implementations provided by libCZI and provide functionality to enumerate available classes. At this point, we can find two variants here - for operating on a file in a file-system and for operating on an http- or https-stream. The http-stream class is based on cURL (https://curl.se/libcurl/), and it needs to be configured in when building libCZI.

Member Function Documentation

◆ CreateDefaultStreamForFile() [1/2]

static std::shared_ptr<libCZI::IStream> libCZI::StreamsFactory::CreateDefaultStreamForFile ( const char *  filename)
static

Creates an instance of the default streams-objects for reading from the file-system.

Parameters
filenameFilename of the file to open (in UTF-8 encoding).
Returns
A new instance of a streams-objects for reading the specified file from the file-system.

◆ CreateDefaultStreamForFile() [2/2]

static std::shared_ptr<libCZI::IStream> libCZI::StreamsFactory::CreateDefaultStreamForFile ( const wchar_t *  filename)
static

Creates an instance of the default streams-objects for reading from the file-system.

Parameters
filenameFilename of the file to open.
Returns
A new instance of a streams-objects for reading the specified file from the file-system.

◆ CreateStream() [1/2]

static std::shared_ptr<libCZI::IStream> libCZI::StreamsFactory::CreateStream ( const CreateStreamInfo stream_info,
const std::string &  file_identifier 
)
static

Creates and initializes a new instance of the specified stream class. If the specified class is not known, then this function will return nullptr. In case of an error when initializing the stream, an exception will be thrown.

Parameters
stream_infoInformation describing the stream.
file_identifierThe filename (or, more generally, a URI of some sort) identifying the file to be opened in UTF8-encoding.
Returns
The newly created and initialized stream.

◆ CreateStream() [2/2]

static std::shared_ptr<libCZI::IStream> libCZI::StreamsFactory::CreateStream ( const CreateStreamInfo stream_info,
const std::wstring &  file_identifier 
)
static

Creates and initializes a new instance of the specified stream class. If the specified class is not known, then this function will return nullptr. In case of an error when initializing the stream, an exception will be thrown.

Parameters
stream_infoInformation describing the stream.
file_identifierThe filename (or, more generally, a URI of some sort) identifying the file to be opened.
Returns
The newly created and initialized stream.

◆ GetStreamClassesCount()

static int libCZI::StreamsFactory::GetStreamClassesCount ( )
static

Gets the number of stream classes available in the factory.

Returns
The number of available stream classes.

◆ GetStreamInfoForClass()

static bool libCZI::StreamsFactory::GetStreamInfoForClass ( int  index,
StreamClassInfo stream_info 
)
static

Gets information about a stream class available in the factory. The function returns false if the index is out of range. The function is idempotent, the information returned from it will not change during the lifetime of the application.

Parameters
indexZero-based index of the class for which information is to be retrieved.
[out]stream_infoInformation describing the stream class.
Returns
True if it succeeds; false otherwise.

◆ GetStreamPropertyBagPropertyInfo()

static const StreamPropertyBagPropertyInfo* libCZI::StreamsFactory::GetStreamPropertyBagPropertyInfo ( int *  count)
static

Gets a (static) list of all properties which can be used for the property bag when creating a stream object. This list is terminated by an entry with a null property_name. The list is static and will not change during the lifetime of the application, the returned pointer is valid until the application terminates. It is pointing to static memory and must not be freed.

Parameters
[out]countIf non-null, the number of valid elements (not including the terminal element) is put here.
Returns
A pointer to an array containing property-bag information.

◆ Initialize()

static void libCZI::StreamsFactory::Initialize ( )
static

Perform one-time initialization of the streams objects. Some stream objects may require some one-time initialization for being operational (this is e.g. the case with the libcurl-based ones). It is considered good practice to call this function before using any of the other methods. Calling it multiple times is not a problem (and subsequent calls after the first are ignored).

Member Data Documentation

◆ kStreamClassInfoProperty_CurlHttp_CaInfo

const char* libCZI::StreamsFactory::kStreamClassInfoProperty_CurlHttp_CaInfo
static

A static string for the property_name for the get_property-function of the StreamClassInfo identifying the build-time configured file holding one or more certificates to verify the peer with. C.f. https://curl.se/libcurl/c/curl_version_info.html, this property gives the value of the "cainfo"-field. If it is null, then an invalid property is returned.

◆ kStreamClassInfoProperty_CurlHttp_CaPath

const char* libCZI::StreamsFactory::kStreamClassInfoProperty_CurlHttp_CaPath
static

A static string for the property_name for the get_property-function of the StreamClassInfo identifying the build-time configured directory holding CA certificates. C.f. https://curl.se/libcurl/c/curl_version_info.html, this property gives the value of the "capath"-field. If it is null, then an invalid property is returned.


The documentation for this class was generated from the following file: