3 /// Blackberry database record parser class for contact records.
7 Copyright (C) 2005-2007, 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_RECORD_CONTACT_H__
23 #define __BARRY_RECORD_CONTACT_H__
35 // NOTE: All classes here must be container-safe! Perhaps add sorting
36 // operators in the future.
40 /// \addtogroup RecordParserClasses
51 GroupLink() : Link(0), Unknown(0) {}
52 GroupLink(uint32_t link
, uint16_t unknown
)
53 : Link(link
), Unknown(unknown
)
57 typedef std::vector
<GroupLink
> GroupLinksType
;
58 typedef std::vector
<UnknownField
> UnknownsType
;
60 // contact specific data
79 DefaultCommunicationsMethod
,
106 GroupLinksType GroupLinks
;
107 UnknownsType Unknowns
;
110 bool m_FirstNameSeen
;
114 const unsigned char* ParseField(const unsigned char *begin
,
115 const unsigned char *end
);
121 uint32_t GetID() const { return RecordId
; }
122 std::string
GetPostalAddress() const;
124 // Parser / Builder API (see parser.h / builder.h)
125 uint8_t GetRecType() const { return RecType
; }
126 uint32_t GetUniqueId() const { return RecordId
; }
127 void SetIds(uint8_t Type
, uint32_t Id
) { RecType
= Type
; RecordId
= Id
; }
128 void ParseHeader(const Data
&data
, size_t &offset
);
129 void ParseFields(const Data
&data
, size_t &offset
);
130 void BuildHeader(Data
&data
, size_t &offset
) const;
131 void BuildFields(Data
&data
, size_t &offset
) const;
133 void Clear(); // erase everything
135 void Dump(std::ostream
&os
) const;
137 // sorting - put group links at the end
138 bool operator<(const Contact
&other
) const {
139 return GroupLinks
.size() == 0 && other
.GroupLinks
.size() > 0;
140 // // testing - put group links at the top
141 // return GroupLinks.size() > 0 && other.GroupLinks.size() == 0;
145 static const char * GetDBName() { return "Address Book"; }
146 static uint8_t GetDefaultRecType() { return 0; }
149 static void SplitName(const std::string
&full
, std::string
&first
, std::string
&last
);
152 inline std::ostream
& operator<< (std::ostream
&os
, const Contact
&contact
) {