Search Toolkit Book for CInputStreamSource
class CInputStreamSource encapsulates details of how we supply applications with input data through sets of command-line options, and permits code to work with a standard API for accepting input data from the command-line. More...
#include <util/stream_source.hpp>
class CInputStreamSource encapsulates details of how we supply applications with input data through sets of command-line options, and permits code to work with a standard API for accepting input data from the command-line.
This class offers many variants for accepting and managing input data. Currently supported modes are:
Once instantiated, this class supports the ability to iterate a set of input streams using the code metaphor:
...
}
class CInputStreamSource encapsulates details of how we supply applications with input data through s...
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
const CharType(& source)[N]
#define GetArgs
Avoid preprocessor name clash with the NCBI C Toolkit.
Streams are checked for error conditions at the start (badbit or failbit before being returned from the iterator) and end (badbit after use, prior to iterating to the next stream), throwing an exception in such case. The former handles cases of files which don't exist, and the latter handles cases of disk read errors without preventing operations line getline (which sets failbit on reading the last line of input, with a terminator).
Definition at line 74 of file stream_source.hpp.
◆ CInputStreamSource() [1/3] CInputStreamSource::CInputStreamSource ( )Default ctor This ctor leaves the stream source empty.
Definition at line 126 of file stream_source.cpp.
◆ CInputStreamSource() [2/3]Initialize our stream source through the arguments provided on a command-line.
This constructor will interpret the commands supplied via SetStandardInputArgs()
Definition at line 132 of file stream_source.cpp.
References InitArgs().
◆ ~CInputStreamSource() CInputStreamSource::~CInputStreamSource ( ) virtualDefinition at line 139 of file stream_source.cpp.
◆ CInputStreamSource() [3/3] ◆ GetCurrentFileName() string CInputStreamSource::GetCurrentFileName ( void ) const ◆ GetCurrentStreamIndex() size_t CInputStreamSource::GetCurrentStreamIndex ( size_t * count =nullptr
) const
Returns the current file index and the total number of files.
Definition at line 401 of file stream_source.cpp.
References count, m_CurrIndex, and m_Files.
◆ GetStream() [1/2] ◆ GetStream() [2/2] ◆ HaveArgsForPrefix() bool CInputStreamSource::HaveArgsForPrefix ( const string & prefix ="input"
) static ◆ InitArgs() ◆ InitFile() void CInputStreamSource::InitFile ( const string & file_path ) ◆ InitFilesInDirSubtree()
Initialize from a file search path.
Definition at line 242 of file stream_source.cpp.
References _TRACE, eUnknown, CDir::Exists(), fFF_File, fFF_Recursive, FindFiles(), m_CurrIndex, m_Files, m_Istr, NCBI_THROW, and Rewind().
Referenced by InitArgs().
◆ InitManifest() void CInputStreamSource::InitManifest ( const string & manifest )Initialize from a manifest file.
Definition at line 221 of file stream_source.cpp.
References _TRACE, all, copy(), eUnknown, CFileManifest::GetAllFilePaths(), m_CurrIndex, m_Files, m_Istr, NCBI_THROW, and Rewind().
Referenced by InitArgs(), and CPrimeCacheApplication::Run().
◆ InitStream()Initialize from a stream No ownership is claimed by this class - lifetime management of the stream is the responsibility of the caller.
Initialize from a given stream which is the sole content.
As precondition, expect that the stream is in a good condition prior to being handed off to consumers.
Definition at line 175 of file stream_source.cpp.
References eUnknown, m_CurrFile, m_CurrIndex, m_Files, m_Istr, and NCBI_THROW.
Referenced by InitArgs(), and CPrimeCacheApplication::Run().
◆ JumpToFile() ◆ operator bool() CInputStreamSource::operator bool ( void ) constDetermine if there are any more streams to be processed.
Definition at line 409 of file stream_source.cpp.
◆ operator*()Dereferencing the stream class returns the current stream.
Definition at line 311 of file stream_source.cpp.
References GetStream().
◆ operator++()Advance to the next stream in the class.
The current stream, if it exists, is in a good condition (badbit or failbit set).
If these conditions aren't met, throws an exception.
Definition at line 373 of file stream_source.cpp.
References x_OpenNextFile(), and x_Reset().
◆ operator=() ◆ RecreateInputArgs() ◆ Rewind() ◆ SetStandardInputArgs()Supply a standard set of arguments via argument descriptions to an application.
Currently supported arguments are:
Any or all of these arguments may be supplied by an application
Definition at line 41 of file stream_source.cpp.
References CArgDescriptions::AddAlias(), CArgDescriptions::AddDefaultKey(), CArgDescriptions::AddKey(), CArgDescriptions::AddOptionalKey(), CArgDescriptions::eExcludes, CArgDescriptions::eInputFile, CArgDescriptions::eRequires, CArgDescriptions::eString, set< Key, Compare >::insert(), s_InputStreamSourcePrefixes, CArgDescriptions::SetCurrentGroup(), and CArgDescriptions::SetDependency().
Referenced by CAlignCleanupApplication::Init(), and CAdvancedAlignCleanup::SetupArgDescriptions().
◆ x_OpenNextFile() void CInputStreamSource::x_OpenNextFile ( ) protectedvirtual ◆ x_OpenOwnedStream() void CInputStreamSource::x_OpenOwnedStream ( CNcbiIstream * is ) protected ◆ x_Reset() void CInputStreamSource::x_Reset ( void ) protected ◆ m_Args CArgs CInputStreamSource::m_Args protected ◆ m_CurrFile string CInputStreamSource::m_CurrFile protected ◆ m_CurrIndex size_t CInputStreamSource::m_CurrIndex protected ◆ m_Files vector<string> CInputStreamSource::m_Files protected ◆ m_Istr ◆ m_IstrOwned ◆ m_Prefix string CInputStreamSource::m_Prefix protectedThe documentation for this class was generated from the following files:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4