From 74ddd0381aa1b1a90eb0d5300fa576cb2348eeac Mon Sep 17 00:00:00 2001 From: John Denker Date: Sun, 17 Oct 2021 10:10:18 -0700 Subject: basically functional, but still a work in progress --- parse_csv.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 parse_csv.h (limited to 'parse_csv.h') diff --git a/parse_csv.h b/parse_csv.h new file mode 100644 index 0000000..362c478 --- /dev/null +++ b/parse_csv.h @@ -0,0 +1,34 @@ +#ifndef PARSE_CSV__H +#define PARSE_CSV__H +#include + +struct qstring : public std::string { + int q; // was explicitly quoted +// Constructors: + qstring(): q(0) {} + qstring(int const _q): q(_q) {} + qstring(std::string const &s): std::string(s), q(0) {} + qstring(std::string const &s, int const _q): std::string(s), q(_q) {} +}; + +// Helper functions, not class member functions: +// Simple case, do nothing: +template inline void set_q(T& target, int const val) {} +template inline int get_q(T const& target) {return 0;} + +// Specialization: Fancy case, actually act on q: +template<> inline void set_q(qstring& target, int const val) { + target.q = val; +} + +template<> inline int get_q(qstring const& target){ + return target.q; +} + +template +std::vector readCSVRow(std::istream& input); + +template +std::vector > readCSV(std::istream &in); + +#endif -- cgit v1.2.3