From: Dennis Doering Date: Tue, 1 Oct 2013 11:11:40 +0000 (+0200) Subject: CSVRow added and Einleitung modified X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=89f46b721de0aef3c156af0ae4683b9da2608d7e;p=radhard.git CSVRow added and Einleitung modified --- diff --git a/newCOMBI/CSVRow.C b/newCOMBI/CSVRow.C new file mode 100755 index 0000000..9bf3cc1 --- /dev/null +++ b/newCOMBI/CSVRow.C @@ -0,0 +1,34 @@ +#include "CSVRow.h" + +#include +#include +#include +#include + + +std::string const& CSVRow::operator[](std::size_t index) const { + return m_data[index]; +} + +std::size_t CSVRow::size() const { + return m_data.size(); +} + +void CSVRow::readNextRow(std::istream& str) { + std::string line; + std::getline(str,line); + + std::stringstream lineStream(line); + std::string cell; + + m_data.clear(); + while(std::getline(lineStream,cell,'\t')) { + m_data.push_back(cell); + } +} + +std::istream& operator>>(std::istream& str,CSVRow& data) { + data.readNextRow(str); + return str; +} + diff --git a/newCOMBI/CSVRow.h b/newCOMBI/CSVRow.h new file mode 100755 index 0000000..c11e33c --- /dev/null +++ b/newCOMBI/CSVRow.h @@ -0,0 +1,22 @@ +#ifndef CSVROW_H +#define CSVROW_H + + +#include +#include + +class CSVRow { +public: + std::string const& operator[](std::size_t index) const; + std::size_t size() const; + void readNextRow(std::istream& str); + + friend std::istream& operator>>(std::istream& str,CSVRow& data); + +private: + std::vector m_data; +}; + +//std::istream& operator>>(std::istream& str,CSVRow& data); + +#endif