2 /// \file r_servicebook.h
3 /// Blackberry database record parser class for the
4 /// Service Book record.
8 Copyright (C) 2005-2011, 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 ParseHeader(const Data
&data
, size_t &offset
);
69 void ParseFields(const Data
&data
, size_t &offset
, const IConverter
*ic
= 0);
70 void BuildHeader(Data
&data
, size_t &offset
) const;
71 void BuildFields(Data
&data
, size_t &offset
, const IConverter
*ic
= 0) const;
75 void Dump(std::ostream
&os
) const;
78 BXEXPORT
inline std::ostream
& operator<<(std::ostream
&os
, const ServiceBookConfig
&msg
) {
84 class ServiceBookData
;
86 class BXEXPORT ServiceBook
88 ServiceBookData
*m_data
;
91 typedef std::vector
<UnknownField
> UnknownsType
;
96 std::string HiddenName
;
97 std::string Description
;
99 std::string BesDomain
;
100 std::string UniqueId
;
101 std::string ContentId
;
102 ServiceBookConfig Config
;
104 UnknownsType Unknowns
;
107 const unsigned char* ParseField(const unsigned char *begin
,
108 const unsigned char *end
, const IConverter
*ic
= 0);
114 // Parser / Builder API (see parser.h / builder.h)
115 uint8_t GetRecType() const { return RecType
; }
116 uint32_t GetUniqueId() const { return RecordId
; }
117 void SetIds(uint8_t Type
, uint32_t Id
) { RecType
= Type
; RecordId
= Id
; }
118 void ParseHeader(const Data
&data
, size_t &offset
);
119 void ParseFields(const Data
&data
, size_t &offset
, const IConverter
*ic
= 0);
120 void BuildHeader(Data
&data
, size_t &offset
) const;
121 void BuildFields(Data
&data
, size_t &offset
, const IConverter
*ic
= 0) const;
123 // operations (common among record classes)
125 void Dump(std::ostream
&os
) const;
126 std::string
GetDescription() const;
129 bool operator<(const ServiceBook
&other
) const;
132 static const char * GetDBName() { return "Service Book"; }
133 static uint8_t GetDefaultRecType() { return 0; }
136 BXEXPORT
inline std::ostream
& operator<<(std::ostream
&os
, const ServiceBook
&msg
) {