From 96a72ab019817d9dc6384a8cbbf5dd1b935ebabc Mon Sep 17 00:00:00 2001 From: Chris Frey Date: Wed, 16 May 2012 00:02:07 -0400 Subject: [PATCH] lib: moved mimedump.h from tools/ into the library (mimeio.h) --- src/mimeio.h | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++- tools/Makefile.am | 1 - tools/bio.cc | 1 - tools/btardump.cc | 1 - tools/btool.cc | 1 - tools/mimedump.h | 93 ------------------------------------------------------- tools/util.cc | 1 - 7 files changed, 87 insertions(+), 99 deletions(-) delete mode 100644 tools/mimedump.h diff --git a/src/mimeio.h b/src/mimeio.h index 75167fec..b57a09c9 100644 --- a/src/mimeio.h +++ b/src/mimeio.h @@ -25,13 +25,99 @@ #include "dll.h" #include "builder.h" +#include "vcard.h" +#include "vevent.h" +#include "vjournal.h" +#include "vtodo.h" #include #include #include -#include +#include namespace Barry { +class Contact; +class Calendar; +class Memo; +class Task; + +// +// Template classes to write MIME data to stream, from record. +// + +template +class MimeDump +{ +public: + static void Dump(std::ostream &os, const Record &rec) + { + os << rec << std::endl; + } + + static bool Supported() { return false; } +}; + +template <> +class MimeDump +{ +public: + static void Dump(std::ostream &os, const Barry::Contact &rec) + { + Barry::Sync::vCard vcard; + os << vcard.ToVCard(rec) << std::endl; + } + + static bool Supported() { return true; } +}; + +template <> +class MimeDump +{ +public: + static void Dump(std::ostream &os, const Barry::Calendar &rec) + { + Barry::Sync::vTimeConverter vtc; + Barry::Sync::vCalendar vcal(vtc); + os << vcal.ToVCal(rec) << std::endl; + } + + static bool Supported() { return true; } +}; + +template <> +class MimeDump +{ +public: + static void Dump(std::ostream &os, const Barry::Memo &rec) + { + Barry::Sync::vTimeConverter vtc; + Barry::Sync::vJournal vjournal(vtc); + os << vjournal.ToMemo(rec) << std::endl; + } + + static bool Supported() { return true; } +}; + +template <> +class MimeDump +{ +public: + static void Dump(std::ostream &os, const Barry::Task &rec) + { + Barry::Sync::vTimeConverter vtc; + Barry::Sync::vTodo vtodo(vtc); + os << vtodo.ToTask(rec) << std::endl; + } + + static bool Supported() { return true; } +}; + + +// +// Builder class, for reading MIME stream data and loading into +// a DBData record. +// + class BXEXPORT MimeBuilder : public Barry::Builder { std::auto_ptr m_ifs; diff --git a/tools/Makefile.am b/tools/Makefile.am index 8eacfbae..05ad5f29 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -13,7 +13,6 @@ DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ noinst_HEADERS = \ i18n.h \ gettext.h \ - mimedump.h \ brecsum.h \ util.h \ boostwrap.h \ diff --git a/tools/bio.cc b/tools/bio.cc index d412b205..8cefa06a 100644 --- a/tools/bio.cc +++ b/tools/bio.cc @@ -23,7 +23,6 @@ #include #include -#include "mimedump.h" #include "brecsum.h" #include "util.h" diff --git a/tools/btardump.cc b/tools/btardump.cc index fa880451..60236d62 100644 --- a/tools/btardump.cc +++ b/tools/btardump.cc @@ -22,7 +22,6 @@ #include #ifdef __BARRY_SYNC_MODE__ #include -#include "mimedump.h" #endif #include #include diff --git a/tools/btool.cc b/tools/btool.cc index 5684fbda..c798722e 100644 --- a/tools/btool.cc +++ b/tools/btool.cc @@ -38,7 +38,6 @@ #include #ifdef __BARRY_SYNC_MODE__ #include -#include "mimedump.h" #endif #ifdef __BARRY_BACKUP_MODE__ #include diff --git a/tools/mimedump.h b/tools/mimedump.h deleted file mode 100644 index ad551f78..00000000 --- a/tools/mimedump.h +++ /dev/null @@ -1,93 +0,0 @@ -/// -/// \file mimedump.h -/// Overloaded templates for handling Mime output -/// - -/* - Copyright (C) 2010-2012, Net Direct Inc. (http://www.netdirect.ca/) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - See the GNU General Public License in the COPYING file at the - root directory of this project for more details. -*/ - -#ifndef __BARRY_TOOLS_MIMEDUMP_H__ -#define __BARRY_TOOLS_MIMEDUMP_H__ - -template -class MimeDump -{ -public: - static void Dump(std::ostream &os, const Record &rec) - { - os << rec << std::endl; - } - - static bool Supported() { return false; } -}; - -template <> -class MimeDump -{ -public: - static void Dump(std::ostream &os, const Barry::Contact &rec) - { - Barry::Sync::vCard vcard; - os << vcard.ToVCard(rec) << std::endl; - } - - static bool Supported() { return true; } -}; - -template <> -class MimeDump -{ -public: - static void Dump(std::ostream &os, const Barry::Calendar &rec) - { - Barry::Sync::vTimeConverter vtc; - Barry::Sync::vCalendar vcal(vtc); - os << vcal.ToVCal(rec) << std::endl; - } - - static bool Supported() { return true; } -}; - -template <> -class MimeDump -{ -public: - static void Dump(std::ostream &os, const Barry::Memo &rec) - { - Barry::Sync::vTimeConverter vtc; - Barry::Sync::vJournal vjournal(vtc); - os << vjournal.ToMemo(rec) << std::endl; - } - - static bool Supported() { return true; } -}; - -template <> -class MimeDump -{ -public: - static void Dump(std::ostream &os, const Barry::Task &rec) - { - Barry::Sync::vTimeConverter vtc; - Barry::Sync::vTodo vtodo(vtc); - os << vtodo.ToTask(rec) << std::endl; - } - - static bool Supported() { return true; } -}; - -#endif - diff --git a/tools/util.cc b/tools/util.cc index 56f9b7fc..dcba2128 100644 --- a/tools/util.cc +++ b/tools/util.cc @@ -24,7 +24,6 @@ #include #ifdef __BARRY_SYNC_MODE__ #include -#include "mimedump.h" #endif #include -- 2.11.4.GIT