Confdump Agent
1.4.0
|
Parses a fixed-width text table into a Result. More...
#include <FixedTable.hpp>
Classes | |
class | Specification |
Helper class to configure the parsing. More... | |
Public Types | |
enum | ParsingMode { DetectWidthsFromHeader, UseSpecifiedHeaders } |
enum | Platform { Windows, Linux } |
Public Member Functions | |
FixedTable () | |
~FixedTable () | |
template<class ElementT > | |
void | readAllInto (QByteArray byteArray, std::vector< boost::shared_ptr< ElementT > > &elements) |
Parse data from a stream. | |
void | setFieldTranslations (const std::map< std::string, std::string > &translations) |
Rename fields on the fly. | |
void | setSpecification (const Specification &spec) |
Provide important configuration options to the parser. | |
Private Member Functions | |
void | readHeaderFrom (const QString Headers) |
bool | readLineFrom (const QString line, boost::shared_ptr< ManagedElement > element) |
void | detectColumnPositionsFromLine (const std::string &line) |
void | checkColumnPositionsFromSpecification (const std::string &line) |
void | splitLineOnColumnPositions (const std::string &line, std::vector< std::string > &columns) |
Private Attributes | |
std::vector< std::string > | header_ |
std::vector < std::string::size_type > | columnPositions_ |
Specification | specification_ |
std::map< std::string, std::string > | fieldTranslations_ |
Parses a fixed-width text table into a Result.
A FixedTable is filled from an input stream containing fixed-width fields and returns this data as a Result. The fields' widths is determined automatically based on the first line of input, which is expected to contain the name of the fields, like this:
Field1 OtherField2 AnotherField3 data data data data data data
Definition at line 52 of file FixedTable.hpp.
Definition at line 55 of file FixedTable.hpp.
Definition at line 61 of file FixedTable.hpp.
Definition at line 45 of file FixedTable.cpp.
Definition at line 49 of file FixedTable.cpp.
void Confdump::System::FixedTable::checkColumnPositionsFromSpecification | ( | const std::string & | line | ) | [private] |
Definition at line 123 of file FixedTable.cpp.
References Confdump::System::FixedTable::Specification::columnHeadsBegin(), Confdump::System::FixedTable::Specification::columnHeadsEnd(), columnPositions_, and specification_.
Referenced by readHeaderFrom().
void Confdump::System::FixedTable::detectColumnPositionsFromLine | ( | const std::string & | line | ) | [private] |
Definition at line 91 of file FixedTable.cpp.
References columnPositions_.
Referenced by readHeaderFrom().
void Confdump::System::FixedTable::readAllInto | ( | QByteArray | byteArray, |
std::vector< boost::shared_ptr< ElementT > > & | elements | ||
) |
Parse data from a stream.
Definition at line 132 of file FixedTable.hpp.
References Confdump::System::FixedTable::Specification::hasHeader(), Linux, Confdump::System::FixedTable::Specification::platform(), readHeaderFrom(), readLineFrom(), and specification_.
void Confdump::System::FixedTable::readHeaderFrom | ( | const QString | Headers | ) | [private] |
Definition at line 53 of file FixedTable.cpp.
References checkColumnPositionsFromSpecification(), detectColumnPositionsFromLine(), DetectWidthsFromHeader, header_, Confdump::System::FixedTable::Specification::parsingMode(), specification_, splitLineOnColumnPositions(), and UseSpecifiedHeaders.
Referenced by readAllInto().
bool Confdump::System::FixedTable::readLineFrom | ( | const QString | line, |
boost::shared_ptr< ManagedElement > | element | ||
) | [private] |
Definition at line 70 of file FixedTable.cpp.
References fieldTranslations_, header_, and splitLineOnColumnPositions().
Referenced by readAllInto().
void Confdump::System::FixedTable::setFieldTranslations | ( | const std::map< std::string, std::string > & | translations | ) |
Rename fields on the fly.
Definition at line 177 of file FixedTable.cpp.
References fieldTranslations_.
void Confdump::System::FixedTable::setSpecification | ( | const Specification & | spec | ) |
Provide important configuration options to the parser.
Definition at line 172 of file FixedTable.cpp.
References specification_.
void Confdump::System::FixedTable::splitLineOnColumnPositions | ( | const std::string & | line, |
std::vector< std::string > & | columns | ||
) | [private] |
Definition at line 156 of file FixedTable.cpp.
References columnPositions_.
Referenced by readHeaderFrom(), and readLineFrom().
std::vector<std::string::size_type> Confdump::System::FixedTable::columnPositions_ [private] |
Definition at line 120 of file FixedTable.hpp.
Referenced by checkColumnPositionsFromSpecification(), detectColumnPositionsFromLine(), and splitLineOnColumnPositions().
std::map<std::string, std::string> Confdump::System::FixedTable::fieldTranslations_ [private] |
Definition at line 122 of file FixedTable.hpp.
Referenced by readLineFrom(), and setFieldTranslations().
std::vector<std::string> Confdump::System::FixedTable::header_ [private] |
Definition at line 119 of file FixedTable.hpp.
Referenced by readHeaderFrom(), and readLineFrom().
Definition at line 121 of file FixedTable.hpp.
Referenced by checkColumnPositionsFromSpecification(), readAllInto(), readHeaderFrom(), and setSpecification().