HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FS_Reader Class Reference

Class for reading files. More...

#include <FS_Reader.h>

+ Inheritance diagram for FS_Reader:

Public Member Functions

 FS_Reader ()
 
 FS_Reader (const char *source, const UT_Options *options=0)
 
 FS_Reader (FS_ReaderStream *sourcestream)
 NOTE: This new FS_Reader takes ownership of the FS_ReaderStream. More...
 
virtual ~FS_Reader ()
 
virtual int64 getMemoryUsage (bool inclusive) const
 Get the amount of memory owned by this FS_Reader. More...
 
void close ()
 
bool isGood ()
 This function is used to check if the file was successfully opened. More...
 
UT_IStreamgetStream () const
 
FS_ReaderStreamshareDataAndGetSubstream (int64 stream_offset, int64 sub_stream_size, int64 sub_data_size, const FS_IStreamFilterFactory *f=nullptr) const
 
time_t getModTime () const
 
int64 getLength () const
 
const UT_StringHoldergetFilename () const
 
FS_IStreamFilterFactorygetSubStreamReadFilterFactory () const
 
FS_WriteFilterFactorygetSubStreamWriteFilterFactory () const
 

Static Public Member Functions

static void addReaderHelper (FS_ReaderHelper *helper)
 
static void removeReaderHelper (FS_ReaderHelper *helper)
 
static bool splitIndexFileSectionPath (const char *source_section_path, UT_String &index_file_path, UT_String &section_name)
 
static bool splitIndexFileSectionPath (const char *source_section_path, UT_StringHolder &index_file_path, UT_StringHolder &section_name)
 
static bool splitIndexFileSectionPath (const char *source_section_path, UT_String &index_file_path, UT_StringArray &section_names)
 
static void combineIndexFileSectionPath (UT_String &source_section_path, const char *index_file_path, const char *section_name)
 
static void combineIndexFileSectionPath (UT_String &source_section_path, const char *index_file_path, const UT_StringArray &section_names)
 

Additional Inherited Members

- Protected Member Functions inherited from UT_NonCopyableNS::UT_NonCopyable
 UT_NonCopyable ()=default
 
 ~UT_NonCopyable ()=default
 
 UT_NonCopyable (const UT_NonCopyable &)=delete
 
UT_NonCopyableoperator= (const UT_NonCopyable &)=delete
 

Detailed Description

Class for reading files.

Definition at line 33 of file FS_Reader.h.

Constructor & Destructor Documentation

FS_Reader::FS_Reader ( )
FS_Reader::FS_Reader ( const char *  source,
const UT_Options options = 0 
)

Use this constructor to create a new reader. The specified file is opened immediately. Common options:

  • "string cache_mode" - Specify the "caching" pattern. This gives a hint to the file system about how the stream will be accessed.
    • "normal" - Normal caching
    • "random" - Access pattern is random
    • "sequential" - Access pattern is sequential
  • "int buffer_size" - Specify the buffer size (see setvbuf)
  • "bool ascii" - Specify whether the file should be opened in ASCII read mode for automatically translating line-endings.
FS_Reader::FS_Reader ( FS_ReaderStream sourcestream)

NOTE: This new FS_Reader takes ownership of the FS_ReaderStream.

virtual FS_Reader::~FS_Reader ( )
virtual

Member Function Documentation

static void FS_Reader::addReaderHelper ( FS_ReaderHelper helper)
static
void FS_Reader::close ( )

Closes the stream. After calling this function, the getStream() function will always return nullptr.

static void FS_Reader::combineIndexFileSectionPath ( UT_String source_section_path,
const char *  index_file_path,
const char *  section_name 
)
static

Utility function to combine index file name and section name into the section path. It asks all registered reader helpers whether they recognize the index_file_path path protocol and can combine it with the section name into the section full path. If none of the helpers do, then it asks FS_IndexFile to combine the components, joining them with '?' by default.

Parameters
[out]source_section_pathThe combined section full path.
[in]index_file_pathThe base path to the index file.
[in]section_nameThe name of the section inside the index file.
[in]section_namesThe names of the nested sections in the index file, with the outermost section at the beginning of the array and the innermost section (contained within the outer sections) at the end of the array. If the array contains only one entry, it's equivalent to the method that takes just a single string.
static void FS_Reader::combineIndexFileSectionPath ( UT_String source_section_path,
const char *  index_file_path,
const UT_StringArray section_names 
)
static

Utility function to combine index file name and section name into the section path. It asks all registered reader helpers whether they recognize the index_file_path path protocol and can combine it with the section name into the section full path. If none of the helpers do, then it asks FS_IndexFile to combine the components, joining them with '?' by default.

Parameters
[out]source_section_pathThe combined section full path.
[in]index_file_pathThe base path to the index file.
[in]section_nameThe name of the section inside the index file.
[in]section_namesThe names of the nested sections in the index file, with the outermost section at the beginning of the array and the innermost section (contained within the outer sections) at the end of the array. If the array contains only one entry, it's equivalent to the method that takes just a single string.
const UT_StringHolder& FS_Reader::getFilename ( ) const
int64 FS_Reader::getLength ( ) const
virtual int64 FS_Reader::getMemoryUsage ( bool  inclusive) const
virtual

Get the amount of memory owned by this FS_Reader.

time_t FS_Reader::getModTime ( ) const
UT_IStream* FS_Reader::getStream ( ) const

This function retrieves the C++ stream object which you can interact with in the normal ways. If this function returns nullptr, the file specified in the constructor could not be found.

FS_IStreamFilterFactory* FS_Reader::getSubStreamReadFilterFactory ( ) const
FS_WriteFilterFactory* FS_Reader::getSubStreamWriteFilterFactory ( ) const
bool FS_Reader::isGood ( )
inline

This function is used to check if the file was successfully opened.

Definition at line 63 of file FS_Reader.h.

static void FS_Reader::removeReaderHelper ( FS_ReaderHelper helper)
static
FS_ReaderStream* FS_Reader::shareDataAndGetSubstream ( int64  stream_offset,
int64  sub_stream_size,
int64  sub_data_size,
const FS_IStreamFilterFactory f = nullptr 
) const
static bool FS_Reader::splitIndexFileSectionPath ( const char *  source_section_path,
UT_String index_file_path,
UT_String section_name 
)
static

Utility fuction to split the original source path into the index file path and the section name. It asks all registered reader helpers whether they recognize the source path protocol and can provide the section name. If none of the helpers do, then it tries FS_IndexFile to split the source path on '?' by default.

Parameters
[in]source_section_pathThe original source path to split.
[out]index_file_pathIf the original source path refers to an index file section, this parameter is set to the index file path. Otherwise, it is set to the source_section_path parameter.
[out]section_nameIf the original source path refers to and index file section, this parameter is set to the name of that section. Otherwise, it is set to an empty string. If there are many nested sections in the source path, then this argument will contain the innermost section name, and the index_file_path will point to the containing section (itself an index file).
[out]section_namesIf the original source path refers to a section that is nested within other sections (that themselves are index files), then this parameter is set to these section names, with the outermost section at the beginning of the array and the innermost section (contained within the outer sections) at the end of the array. If there is just a single section, the array will contain just one entry (ie, the single section name), and the call will be equivalent to the method that takes just the single string.
Returns
True if the path refered to a section name and the outgoing parameter 'section_name' contains a non-empty string; otherwise, returns false.
static bool FS_Reader::splitIndexFileSectionPath ( const char *  source_section_path,
UT_StringHolder index_file_path,
UT_StringHolder section_name 
)
static

Utility fuction to split the original source path into the index file path and the section name. It asks all registered reader helpers whether they recognize the source path protocol and can provide the section name. If none of the helpers do, then it tries FS_IndexFile to split the source path on '?' by default.

Parameters
[in]source_section_pathThe original source path to split.
[out]index_file_pathIf the original source path refers to an index file section, this parameter is set to the index file path. Otherwise, it is set to the source_section_path parameter.
[out]section_nameIf the original source path refers to and index file section, this parameter is set to the name of that section. Otherwise, it is set to an empty string. If there are many nested sections in the source path, then this argument will contain the innermost section name, and the index_file_path will point to the containing section (itself an index file).
[out]section_namesIf the original source path refers to a section that is nested within other sections (that themselves are index files), then this parameter is set to these section names, with the outermost section at the beginning of the array and the innermost section (contained within the outer sections) at the end of the array. If there is just a single section, the array will contain just one entry (ie, the single section name), and the call will be equivalent to the method that takes just the single string.
Returns
True if the path refered to a section name and the outgoing parameter 'section_name' contains a non-empty string; otherwise, returns false.
static bool FS_Reader::splitIndexFileSectionPath ( const char *  source_section_path,
UT_String index_file_path,
UT_StringArray section_names 
)
static

Utility fuction to split the original source path into the index file path and the section name. It asks all registered reader helpers whether they recognize the source path protocol and can provide the section name. If none of the helpers do, then it tries FS_IndexFile to split the source path on '?' by default.

Parameters
[in]source_section_pathThe original source path to split.
[out]index_file_pathIf the original source path refers to an index file section, this parameter is set to the index file path. Otherwise, it is set to the source_section_path parameter.
[out]section_nameIf the original source path refers to and index file section, this parameter is set to the name of that section. Otherwise, it is set to an empty string. If there are many nested sections in the source path, then this argument will contain the innermost section name, and the index_file_path will point to the containing section (itself an index file).
[out]section_namesIf the original source path refers to a section that is nested within other sections (that themselves are index files), then this parameter is set to these section names, with the outermost section at the beginning of the array and the innermost section (contained within the outer sections) at the end of the array. If there is just a single section, the array will contain just one entry (ie, the single section name), and the call will be equivalent to the method that takes just the single string.
Returns
True if the path refered to a section name and the outgoing parameter 'section_name' contains a non-empty string; otherwise, returns false.

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