1 #ifndef CARMA_SERVICES_TABLE_H
2 #define CARMA_SERVICES_TABLE_H
25 #include <sys/types.h>
51 Column(
int start_column,
int end_column);
53 Column(
int dcol,
int mcol,
int scol);
55 Column(std::string column_name);
141 Table(
const std::string& fileName,
int maxRows=0);
169 void open(
const std::string& fileName,
int maxRows=0);
177 struct stat status(const std::string & fileName );
201 std::vector<std::string>
getColumn(const std::string& column) const;
209 std::vector<std::string>
getColumn(const int column) const;
232 std::vector<std::string>
getColumn(const int col1, const int col2) const;
239 std::vector<bool>
getBoolColumn(const std::string& column) const;
253 std::vector<bool>
getBoolColumn(const int col1, const int col2) const;
298 const int col2) const;
307 std::vector<int>
getIntColumn(const std::string& column) const;
325 const int col2) const;
333 std::vector<double>
getDMSColumn(const std::string& column) const;
341 std::vector<double>
getDMSColumn(const int column) const;
349 std::vector<double>
getDMSColumn(const std::string& hcolumn, const std::string& mcolumn, const std::string& scolumn) const;
357 std::vector<double>
getDMSColumn(const int dcolumn, const int mcolumn, const int scolumn) const;
365 std::vector<double>
getHMSColumn(const std::string& column) const;
373 std::vector<double>
getHMSColumn(const int column) const;
381 std::vector<double>
getHMSColumn(const std::string& hcolumn, const std::string& mcolumn, const std::string& scolumn) const;
389 std::vector<double>
getHMSColumn(const int hcolumn, const int mcolumn, const int scolumn) const;
424 std::vector<int>
getIntRow(const int row) const;
431 std::vector<std::string>
getStringRow(const int row) const;
439 std::string
getRow(const int row) const;
446 void
putRow(const int row, const std::string& data);
453 void
addRow(const std::string& data);
511 inline std::vector<std::string> getColumnTypes()
const
537 void setColumnName(
const int column,
const std::string& name);
544 void setColumnType(
const int column,
const std::string& name);
551 void setColumnUnit(
const int column,
const std::string& name);
568 int find(
const std::string& query,
569 const int column = 0,
570 bool caseSensitive =
false);
593 int find(
const std::string& query,
594 const std::string& columnName,
595 bool caseSensitive =
false);
608 std::vector<std::string> header_;
609 std::vector<std::string> data_;
611 std::vector<std::string> colnames_;
612 std::vector<std::string> coltypes_;
613 std::vector<std::string> colunits_;
624 std::string word(
const std::string& line,
const int n,
625 const bool end=
false)
const;
632 void Tokenize(
const std::string& line,
633 std::vector<std::string>& tokens,
634 const std::string& delimiters);
645 int indexToken(
const std::vector<std::string>& tokens,
646 const std::string& name,
647 const bool single=
true)
const;
651 bool CommentKey(
const std::string& line,
const std::string& key);
656 double dms(
const char *s)
const;
661 void throwBadColumnByNum(
const int column )
const;
671 ::std::string _filename;
695 #endif // CARMA_SERVICES_TABLE_H
std::vector< double > getDMSColumn(const std::string &column) const
std::ostream & operator<<(::std::ostream &os, const carma::dbms::Table &table)
std::vector< double > getDoubleRow(const int row) const
std::vector< std::string > getColumnUnits() const
std::vector< std::string > getColumnNames() const
std::string getColumnUnit(const int column=-1) const
int getColumnNumber(const std::string &colname) const
void removeRow(const int row)
std::string getColumnName(const int column=-1) const
void setColumnName(const int column, const std::string &name)
std::vector< std::string > getStringRow(const int row) const
std::vector< int > getIntColumn(const std::string &column) const
Read a column from the Table as integers.
std::vector< bool > getBoolColumn(const std::string &column) const
get a boolean column
Column - an unimplemented class we could create a special class 'Column' in which it is defined how a...
std::string getRow(const int row) const
::std::string getPathAndFileName()
Return the current full path+filename.
std::vector< double > getHMSColumn(const std::string &column) const
void addRow(const std::string &data)
std::vector< double > getDoubleColumnAndVerify(const std::string &column) const
Read a column from the Table as doubles.
std::vector< double > getDoubleColumn(const std::string &column) const
Read a column from the Table as doubles.
Table()
Default constructor, creates an empty table.
Simple ASCII Table format, fully memory based.
std::vector< std::string > getColumn(const std::string &column) const
get column data by name
int find(const std::string &query, const int column=0, bool caseSensitive=false)
Find the row that matches the queried name and column number.
std::vector< std::string > getCommentColumn(const std::string &column) const
this special case grabs the last set of columns in a verbatim style (i.e preserving the embedded spac...
void putRow(const int row, const std::string &data)
std::vector< int > getIntRow(const int row) const
void reRead()
reRead calls open on whatever file is currently open
bool hasBeenModified()
hasBeenModified checks if the currently open file has been modified Returns true|false depending on i...
void open(const std::string &fileName, int maxRows=0)
open and read table This munges the whole table, reads the header and stores the data in ASCII...
void setColumnUnit(const int column, const std::string &name)
void setColumnType(const int column, const std::string &name)
std::string getColumnType(const int column=-1) const