]> jspc29.x-matter.uni-frankfurt.de Git - radhard.git/commitdiff
CSVRow added and Einleitung modified
authorDennis Doering <dennis@jspc31.x-matter.uni-frankfurt.de>
Tue, 1 Oct 2013 11:11:40 +0000 (13:11 +0200)
committerDennis Doering <dennis@jspc31.x-matter.uni-frankfurt.de>
Tue, 1 Oct 2013 11:11:40 +0000 (13:11 +0200)
newCOMBI/CSVRow.C [new file with mode: 0755]
newCOMBI/CSVRow.h [new file with mode: 0755]

diff --git a/newCOMBI/CSVRow.C b/newCOMBI/CSVRow.C
new file mode 100755 (executable)
index 0000000..9bf3cc1
--- /dev/null
@@ -0,0 +1,34 @@
+#include "CSVRow.h"
+
+#include <iostream>
+#include <sstream>
+#include <vector>
+#include <string>
+
+
+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 (executable)
index 0000000..c11e33c
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef CSVROW_H
+#define CSVROW_H
+
+
+#include <vector>
+#include <string>
+
+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<std::string>    m_data;
+};
+
+//std::istream& operator>>(std::istream& str,CSVRow& data);
+
+#endif