Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __BARRY_MIMEIO_H__
00024 #define __BARRY_MIMEIO_H__
00025
00026 #include "dll.h"
00027 #include "builder.h"
00028 #include "vcard.h"
00029 #include "vevent.h"
00030 #include "vjournal.h"
00031 #include "vtodo.h"
00032 #include <string>
00033 #include <vector>
00034 #include <memory>
00035 #include <iostream>
00036
00037 namespace Barry {
00038
00039 class Contact;
00040 class Calendar;
00041 class Memo;
00042 class Task;
00043
00044
00045
00046
00047
00048 template <class Record>
00049 class MimeDump
00050 {
00051 public:
00052 static void Dump(std::ostream &os, const Record &rec)
00053 {
00054 os << rec << std::endl;
00055 }
00056
00057 static bool Supported() { return false; }
00058 };
00059
00060 template <>
00061 class MimeDump<Barry::Contact>
00062 {
00063 public:
00064 static void Dump(std::ostream &os, const Barry::Contact &rec)
00065 {
00066 Barry::Sync::vCard vcard;
00067 os << vcard.ToVCard(rec) << std::endl;
00068 }
00069
00070 static bool Supported() { return true; }
00071 };
00072
00073 template <>
00074 class MimeDump<Barry::Calendar>
00075 {
00076 public:
00077 static void Dump(std::ostream &os, const Barry::Calendar &rec)
00078 {
00079 Barry::Sync::vTimeConverter vtc;
00080 Barry::Sync::vCalendar vcal(vtc);
00081 os << vcal.ToVCal(rec) << std::endl;
00082 }
00083
00084 static bool Supported() { return true; }
00085 };
00086
00087 template <>
00088 class MimeDump<Barry::Memo>
00089 {
00090 public:
00091 static void Dump(std::ostream &os, const Barry::Memo &rec)
00092 {
00093 Barry::Sync::vTimeConverter vtc;
00094 Barry::Sync::vJournal vjournal(vtc);
00095 os << vjournal.ToMemo(rec) << std::endl;
00096 }
00097
00098 static bool Supported() { return true; }
00099 };
00100
00101 template <>
00102 class MimeDump<Barry::Task>
00103 {
00104 public:
00105 static void Dump(std::ostream &os, const Barry::Task &rec)
00106 {
00107 Barry::Sync::vTimeConverter vtc;
00108 Barry::Sync::vTodo vtodo(vtc);
00109 os << vtodo.ToTask(rec) << std::endl;
00110 }
00111
00112 static bool Supported() { return true; }
00113 };
00114
00115
00116
00117
00118
00119
00120
00121 class BXEXPORT MimeBuilder : public Barry::Builder
00122 {
00123 std::auto_ptr<std::ifstream> m_ifs;
00124 std::istream &m_is;
00125
00126 public:
00127 explicit MimeBuilder(const std::string &filename);
00128 explicit MimeBuilder(std::istream &is);
00129
00130 bool BuildRecord(DBData &data, size_t &offset, const IConverter *ic);
00131 bool FetchRecord(DBData &data, const IConverter *ic);
00132 bool EndOfFile() const;
00133
00134
00135 static bool ReadMimeRecord(std::istream &is, std::string &vrec,
00136 std::vector<std::string> &types);
00137
00138
00139 static bool IsMember(const std::string &item,
00140 const std::vector<std::string> &types);
00141 };
00142
00143 }
00144
00145 #endif
00146