lib: libbarryalx depends on libbarry for the ErrnoError exception
[barry.git] / src / vcard.h
blob4e86ffe4a1a250ca45986e2cc400e45847a2f15e
1 ///
2 /// \file vcard.h
3 /// Conversion routines for vcards
4 ///
6 /*
7 Copyright (C) 2006-2010, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #ifndef __BARRY_SYNC_VCARD_H__
23 #define __BARRY_SYNC_VCARD_H__
25 #include "dll.h"
26 #include "vbase.h"
27 #include "r_contact.h"
28 #include <stdint.h>
29 #include <string>
31 namespace Barry { namespace Sync {
34 // vCard
36 /// Class for converting between RFC 2425/2426 vCard data format,
37 /// and the Barry::Contact class.
38 ///
39 class BXEXPORT vCard : public vBase
41 // data to pass to external requests
42 char *m_gCardData; // dynamic memory returned by vformat()... can
43 // be used directly by the plugin, without
44 // overmuch allocation and freeing (see Extract())
45 std::string m_vCardData;// copy of m_gCardData, for C++ use
46 Barry::Contact m_BarryContact;
48 protected:
49 void AddAddress(const char *rfc_type, const Barry::PostalAddress &addr);
50 void AddCategories(const Barry::CategoryList &categories);
51 void AddPhoneCond(const std::string &phone);
52 void AddPhoneCond(const char *rfc_type, const std::string &phone);
54 void ParseAddress(vAttr &adr, Barry::PostalAddress &address);
55 void ParseCategories(vAttr &cat, Barry::CategoryList &cats);
57 public:
58 vCard();
59 ~vCard();
61 const std::string& ToVCard(const Barry::Contact &con);
62 const Barry::Contact& ToBarry(const char *vcal, uint32_t RecordId);
64 const std::string& GetVCard() const { return m_vCardData; }
65 const Barry::Contact& GetBarryContact() const { return m_BarryContact; }
67 char* ExtractVCard();
69 void Clear();
71 // This is the v-name of the innermost BEGIN/END block
72 static const char* GetVName() { return "VCARD"; }
75 }} // namespace Barry::Sync
77 #endif