From 89f46b721de0aef3c156af0ae4683b9da2608d7e Mon Sep 17 00:00:00 2001 From: Dennis Doering Date: Tue, 1 Oct 2013 13:11:40 +0200 Subject: [PATCH] CSVRow added and Einleitung modified --- newCOMBI/CSVRow.C | 34 ++++++++++++++++++++++++++++++++++ newCOMBI/CSVRow.h | 22 ++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100755 newCOMBI/CSVRow.C create mode 100755 newCOMBI/CSVRow.h 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 -- 2.43.0