2 /// \file r_servicebook.h
3 /// Blackberry database record parser class for the
4 /// Service Book record.
8 Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/)
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 See the GNU General Public License in the COPYING file at the
20 root directory of this project for more details.
23 #ifndef __BARRY_RECORD_SERVICEBOOK_H__
24 #define __BARRY_RECORD_SERVICEBOOK_H__
36 // forward declarations
40 // NOTE: All classes here must be container-safe! Perhaps add sorting
41 // operators in the future.
45 /// \addtogroup RecordParserClasses
48 // This is a packed field, which is a group of fields packed in
49 // variable length records inside one larger field of a normal record.
50 class BXEXPORT ServiceBookConfig
53 typedef Barry::UnknownsType UnknownsType
;
57 UnknownsType Unknowns
;
60 const unsigned char* ParseField(const unsigned char *begin
,
61 const unsigned char *end
, const IConverter
*ic
= 0);
67 // Parser / Builder API (see parser.h / builder.h)
68 void Validate() const;
69 void ParseHeader(const Data
&data
, size_t &offset
);
70 void ParseFields(const Data
&data
, size_t &offset
, const IConverter
*ic
= 0);
71 void BuildHeader(Data
&data
, size_t &offset
) const;
72 void BuildFields(Data
&data
, size_t &offset
, const IConverter
*ic
= 0) const;
76 void Dump(std::ostream
&os
) const;
79 BXEXPORT
inline std::ostream
& operator<<(std::ostream
&os
, const ServiceBookConfig
&msg
) {
85 class ServiceBookData
;
87 class BXEXPORT ServiceBook
89 ServiceBookData
*m_data
;
92 typedef std::vector
<UnknownField
> UnknownsType
;
97 std::string HiddenName
;
98 std::string Description
;
100 std::string BesDomain
;
101 std::string UniqueId
;
102 std::string ContentId
;
103 ServiceBookConfig Config
;
105 UnknownsType Unknowns
;
108 const unsigned char* ParseField(const unsigned char *begin
,
109 const unsigned char *end
, const IConverter
*ic
= 0);
115 // Parser / Builder API (see parser.h / builder.h)
116 void Validate() const;
117 uint8_t GetRecType() const { return RecType
; }
118 uint32_t GetUniqueId() const { return RecordId
; }
119 void SetIds(uint8_t Type
, uint32_t Id
) { RecType
= Type
; RecordId
= Id
; }
120 void ParseHeader(const Data
&data
, size_t &offset
);
121 void ParseFields(const Data
&data
, size_t &offset
, const IConverter
*ic
= 0);
122 void BuildHeader(Data
&data
, size_t &offset
) const;
123 void BuildFields(Data
&data
, size_t &offset
, const IConverter
*ic
= 0) const;
125 // operations (common among record classes)
127 void Dump(std::ostream
&os
) const;
128 std::string
GetDescription() const;
131 bool operator<(const ServiceBook
&other
) const;
134 static const char * GetDBName() { return "Service Book"; }
135 static uint8_t GetDefaultRecType() { return 0; }
137 // Generic Field Handle support
138 static const FieldHandle
<ServiceBook
>::ListT
& GetFieldHandles();
141 BXEXPORT
inline std::ostream
& operator<<(std::ostream
&os
, const ServiceBook
&msg
) {