Class used to represent a source (file or command output) from which metrics can be matched.
More...
#include <Source.h>
|
| Source (const std::string &filePath) noexcept |
| Construct a new Source object of file type. More...
|
|
| Source (const std::string &program, const std::vector< std::string > &arguments) noexcept |
| Construct a new Source object of command type. More...
|
|
SourceType | type () |
| Returns the source type. More...
|
|
const std::string & | path () const noexcept |
| Returns the file path or command to execute. More...
|
|
const std::vector< std::string > & | pathParts () const noexcept |
| For file sources, returns the different parts of the file's path. More...
|
|
const std::string_view & | contents () const noexcept |
| Returns the stored contents (file contents or command output) More...
|
|
std::chrono::system_clock::time_point | timestamp () const noexcept |
| Returns the timestamp of stored contents. More...
|
|
std::vector< std::shared_ptr< Expression > > & | expressions () noexcept |
| Returns the array of the receiver's expressions. More...
|
|
const std::vector< std::shared_ptr< Expression > > & | expressions () const noexcept |
| Returns the array of the receiver's expressions. More...
|
|
bool | reset () noexcept |
| Resets the source: attempts to open the file or execute the command, allocates enough space for contents. More...
|
|
bool | update () noexcept |
| Updates the source (read the file or execute command) and store the results. More...
|
|
std::string_view::const_iterator | begin () const noexcept |
| Returns the iterator to the beginning of the source's contents. More...
|
|
std::string_view::const_iterator | end () const noexcept |
| Returns the iterator to the end of the source's contents. More...
|
|
std::string_view::const_iterator | getLine (std::string_view::const_iterator begin) const noexcept |
| Returns an iterator to the end of the specified line. More...
|
|
|
size_t | readFile (bool firstTime=false) |
| For file sources, put the file contents into the buffer_. More...
|
|
size_t | executeCommand (bool firstTime=false) |
| For command sources, put the command output into the buffer_. More...
|
|
Class used to represent a source (file or command output) from which metrics can be matched.
Definition at line 39 of file Source.h.
◆ SourceType
Enum of existing source type.
Enumerator |
---|
SourceTypeFile | File contents source.
|
SourceTypeCommand | Command output source.
|
Definition at line 44 of file Source.h.
◆ Source() [1/2]
AnyCollect::Source::Source |
( |
const std::string & |
filePath | ) |
|
|
noexcept |
Construct a new Source object of file type.
- Parameters
-
filePath | the path of the file to read |
Definition at line 31 of file Source.cc.
◆ Source() [2/2]
AnyCollect::Source::Source |
( |
const std::string & |
program, |
|
|
const std::vector< std::string > & |
arguments |
|
) |
| |
|
noexcept |
Construct a new Source object of command type.
- Parameters
-
program | main command to execute |
arguments | arguments to be added after the command |
Definition at line 41 of file Source.cc.
◆ begin()
std::string_view::const_iterator AnyCollect::Source::begin |
( |
| ) |
const |
|
noexcept |
Returns the iterator to the beginning of the source's contents.
- Returns
- iterator to the beginning of the source's contents
Definition at line 182 of file Source.cc.
◆ contents()
const std::string_view & AnyCollect::Source::contents |
( |
| ) |
const |
|
noexcept |
Returns the stored contents (file contents or command output)
Definition at line 80 of file Source.cc.
◆ end()
std::string_view::const_iterator AnyCollect::Source::end |
( |
| ) |
const |
|
noexcept |
Returns the iterator to the end of the source's contents.
- Returns
- iterator to the end of the source's contents
Definition at line 186 of file Source.cc.
◆ executeCommand()
size_t AnyCollect::Source::executeCommand |
( |
bool |
firstTime = false | ) |
|
|
protected |
For command sources, put the command output into the buffer_.
Definition at line 118 of file Source.cc.
◆ expressions() [1/2]
std::vector< std::shared_ptr< Expression > > & AnyCollect::Source::expressions |
( |
| ) |
|
|
noexcept |
Returns the array of the receiver's expressions.
Definition at line 88 of file Source.cc.
◆ expressions() [2/2]
const std::vector< std::shared_ptr< Expression > > & AnyCollect::Source::expressions |
( |
| ) |
const |
|
noexcept |
Returns the array of the receiver's expressions.
Definition at line 92 of file Source.cc.
◆ filePathsMatchingGlobbingPattern()
std::vector< std::string > AnyCollect::Source::filePathsMatchingGlobbingPattern |
( |
const std::string & |
pattern | ) |
|
|
staticnoexcept |
Returns all file paths that match a pattern as defined by POSIX.
- Parameters
-
- Returns
- std::vector<std::string>
Definition at line 51 of file Source.cc.
◆ getLine()
std::string_view::const_iterator AnyCollect::Source::getLine |
( |
std::string_view::const_iterator |
begin | ) |
const |
|
noexcept |
Returns an iterator to the end of the specified line.
- Parameters
-
begin | the line to find an end to |
- Returns
- iterator to the first end of line (or end of file) character after the specified iterator
Definition at line 190 of file Source.cc.
◆ path()
const std::string & AnyCollect::Source::path |
( |
| ) |
const |
|
noexcept |
Returns the file path or command to execute.
Definition at line 72 of file Source.cc.
◆ pathParts()
const std::vector< std::string > & AnyCollect::Source::pathParts |
( |
| ) |
const |
|
noexcept |
For file sources, returns the different parts of the file's path.
Definition at line 76 of file Source.cc.
◆ readFile()
size_t AnyCollect::Source::readFile |
( |
bool |
firstTime = false | ) |
|
|
protected |
For file sources, put the file contents into the buffer_.
Definition at line 97 of file Source.cc.
◆ reset()
bool AnyCollect::Source::reset |
( |
| ) |
|
|
noexcept |
Resets the source: attempts to open the file or execute the command, allocates enough space for contents.
- Returns
- true if everything is setup correctly
-
false otherwise
Definition at line 132 of file Source.cc.
◆ timestamp()
std::chrono::system_clock::time_point AnyCollect::Source::timestamp |
( |
| ) |
const |
|
noexcept |
Returns the timestamp of stored contents.
Definition at line 84 of file Source.cc.
◆ type()
Returns the source type.
Definition at line 68 of file Source.cc.
◆ update()
bool AnyCollect::Source::update |
( |
| ) |
|
|
noexcept |
Updates the source (read the file or execute command) and store the results.
- Returns
- true if everything is ok
-
false otherwise
Definition at line 161 of file Source.cc.
◆ buffer_
std::vector<char> AnyCollect::Source::buffer_ |
|
protected |
Buffer for file contents or command output.
Definition at line 55 of file Source.h.
◆ contents_
std::string_view AnyCollect::Source::contents_ |
|
protected |
Read-only view on the buffer_.
Definition at line 57 of file Source.h.
◆ expressions_
std::vector<std::shared_ptr<Expression> > AnyCollect::Source::expressions_ |
|
protected |
Array of expressions used on the source's contents.
Definition at line 60 of file Source.h.
◆ file_
std::ifstream AnyCollect::Source::file_ |
|
protected |
For file sources, the file descriptor.
Definition at line 53 of file Source.h.
◆ path_
std::string AnyCollect::Source::path_ |
|
protected |
Path of the file or command to execute.
Definition at line 51 of file Source.h.
◆ pathParts_
std::vector<std::string> AnyCollect::Source::pathParts_ |
|
protected |
For file sources, the parts of the file's path.
Definition at line 52 of file Source.h.
◆ process_
redi::ipstream AnyCollect::Source::process_ |
|
protected |
For command sources, the child process.
Definition at line 54 of file Source.h.
◆ timestamp_
std::chrono::system_clock::time_point AnyCollect::Source::timestamp_ |
|
protected |
Last contents or output fetching time.
Definition at line 58 of file Source.h.
◆ type_
The type of the source.
Definition at line 50 of file Source.h.
The documentation for this class was generated from the following files: