From 7e0d50d0a57338b0bcf5ca88ad2f105d0068bb59 Mon Sep 17 00:00:00 2001 From: randomdan Date: Mon, 14 Feb 2011 10:54:32 +0000 Subject: Convert dumpTask into a generic purpose file* writer Fully implement view support in p2console --- project2/fileStrmVarWriter.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 project2/fileStrmVarWriter.cpp (limited to 'project2/fileStrmVarWriter.cpp') diff --git a/project2/fileStrmVarWriter.cpp b/project2/fileStrmVarWriter.cpp new file mode 100644 index 0000000..f3812ce --- /dev/null +++ b/project2/fileStrmVarWriter.cpp @@ -0,0 +1,60 @@ +#include "fileStrmVarWriter.h" +#include "rowSet.h" +#include "xmlObjectLoader.h" +#include +#include +#include + +FileStreamVariableWriter::FileStreamVariableWriter(FILE * o, bool q) : + out(o), + quoting(q) +{ +} + +FileStreamVariableWriter::~FileStreamVariableWriter() +{ +} + +void FileStreamVariableWriter::operator()(const long long int & i) const { + fprintf(out, "%lld", i); +} +void FileStreamVariableWriter::operator()(const long int & i) const { + fprintf(out, "%ld", i); +} +void FileStreamVariableWriter::operator()(const int & i) const { + fprintf(out, "%d", i); +} +void FileStreamVariableWriter::operator()(const short int & i) const { + fprintf(out, "%hd", i); +} +void FileStreamVariableWriter::operator()(const long long unsigned int & i) const { + fprintf(out, "%llu", i); +} +void FileStreamVariableWriter::operator()(const long unsigned int & i) const { + fprintf(out, "%lu", i); +} +void FileStreamVariableWriter::operator()(const unsigned int & i) const { + fprintf(out, "%u", i); +} +void FileStreamVariableWriter::operator()(const short unsigned int & i) const { + fprintf(out, "%hu", i); +} +void FileStreamVariableWriter::operator()(const float & i) const { + fprintf(out, "%g", i); +} +void FileStreamVariableWriter::operator()(const double & i) const { + fprintf(out, "%g", i); +} +void FileStreamVariableWriter::operator()(const Glib::ustring & i) const { + fprintf(out, "'%.*s'", i.length(), i.c_str()); +} +void FileStreamVariableWriter::operator()(const boost::shared_ptr & i) const { + fprintf(out, "'%.*s'", i->length(), i->c_str()); +} +void FileStreamVariableWriter::operator()(const boost::posix_time::ptime & i) const { + fprintf(out, "[%s]", boost::posix_time::to_iso_extended_string(i).c_str()); +} +void FileStreamVariableWriter::operator()(const boost::shared_ptr & i) const { + fprintf(out, "[%s]", boost::posix_time::to_iso_extended_string(*i).c_str()); +} + -- cgit v1.2.3