HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FS_ReaderHelper Class Referenceabstract

#include <FS_Reader.h>

+ Inheritance diagram for FS_ReaderHelper:

Public Member Functions

 FS_ReaderHelper ()
 
virtual ~FS_ReaderHelper ()
 
virtual FS_ReaderStreamcreateStream (const char *source, const UT_Options *options=nullptr)=0
 
virtual bool splitIndexFileSectionPath (const char *source_section_path, UT_String &index_file_path, UT_String &section_name)
 
virtual bool combineIndexFileSectionPath (UT_String &source_section_path, const char *index_file_path, const char *section_name)
 

Detailed Description

This class provides a plug-in method for adding a custom "file-system"

See Also
FS_WriterHelper, FS_InfoHelper
Examples:
FS/FS_HomeHelper.h.

Definition at line 180 of file FS_Reader.h.

Constructor & Destructor Documentation

FS_ReaderHelper::FS_ReaderHelper ( )
inline

Definition at line 183 of file FS_Reader.h.

virtual FS_ReaderHelper::~FS_ReaderHelper ( )
inlinevirtual

Definition at line 185 of file FS_Reader.h.

Member Function Documentation

virtual bool FS_ReaderHelper::combineIndexFileSectionPath ( UT_String source_section_path,
const char *  index_file_path,
const char *  section_name 
)
inlinevirtual

Utility function to combine index file name and section name into the section path. Performs the reverse of splitIndexFileSectionPath(). If the helper does not use '?' for any special purpose in the source path, then it does not need to override this virtual (see above).

Parameters
[out]source_section_pathThe combined full section path.
[in]index_file_pathThe base path to the index file.
[in]section_nameThe name of the section inside the index file.
Returns
True if the helper recognizes the 'index_file_path' as its own file protocol. False, if it does not recognize the protocol or if it wants the default joining of file and section names using the default convention of '?' to join the components.

Reimplemented in HDK_Sample::FS_HomeReadHelper.

Definition at line 270 of file FS_Reader.h.

virtual FS_ReaderStream* FS_ReaderHelper::createStream ( const char *  source,
const UT_Options options = nullptr 
)
pure virtual

Return an FS_ReaderStream if the helper is able to open the source filename.

The options are passed through directly from the FS_Reader constructor. See FS_Reader for list of options.

Implemented in HDK_Sample::FS_HomeReadHelper, OP_DataBlockReadHelper, and FS_IconReadHelper.

virtual bool FS_ReaderHelper::splitIndexFileSectionPath ( const char *  source_section_path,
UT_String index_file_path,
UT_String section_name 
)
inlinevirtual

Parse the source path into the index file path and the section name.

The FS library recognizes a special source format for FS_IndexFile, which is a file containing several sections indexed and accessible by their name. That source format contains '?' as a separator between the file path and the section name. FS_Reader scans for '?' in the source path before asking helpers to handle it. This way index files are supported for custom protoclos automatically without them needing to implement it explicitly. Eg, "myfiles:path/to/indexfile?section" will work automaticaly, since FS_Reader will ask the helper for a read stream for "myfiles:/path/to/indexfile" but will create and use the "section" read stream itself. The downside is that custom protocols can't use '?' in their path format. To address this isse, this method has been added to let the helpers decide how to handle the '?'.

If the helper does not use '?' for any special purpose, it does not need to override this virtual (or it can overloaded it and return false). If the helper uses '?' for some special meaning (or if it supports some custom syntax to refer to sections of an index file), then it should override it and return true. Further, it can return a non-empty section name if the protocol supports section naming and the source path indeed refers to a section in an index file. Or, it can return an empty string for the section name, if the source path does not refer to an index file (or if helper does not want the automatic index file handling and plans to handle index files explicitly by itself).

Parameters
[in]source_section_pathOriginal source path to be opened for reading.
[out]index_file_pathIf source_section_path refers to a section in an index file, then this parameter is set to the index file path (and method returns true). If source_section_path does not refer to a section, then this parameter is set to original path, ie, equal to source_section_path (and method returns true). If the helper does not recognize the source_section_path (ie, it's another protocol), or if recognizes it but does not need (nor want) custom handling for '?' separator, then this parameter is not set (and method returns false).
[out]section_nameThis Similar to index_file_path, but this outgoing parameter is set to the section name, if source_section_path refers to a section and is set to empty-string if it does not (and method returns true). If the method returns false, it is not set.
Returns
True if the source_section_path can be handled by the helper, in which case index_file_path and section_name are also set (though section can be an empty-string). False if the source_code_path is not handled by helper, or if helper wants default index file naming convention (with '?' splitting the file and section name).

Reimplemented in HDK_Sample::FS_HomeReadHelper.

Definition at line 251 of file FS_Reader.h.


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