Bumped copyright dates for 2013
[barry.git] / src / r_servicebook.h
blob96b2933a979cbd2cb3779676e1f814e472b0c39d
1 ///
2 /// \file r_servicebook.h
3 /// Blackberry database record parser class for the
4 /// Service Book record.
5 ///
7 /*
8 Copyright (C) 2005-2013, 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__
26 #include "dll.h"
27 #include "record.h"
28 #include <iosfwd>
29 #include <string>
30 #include <vector>
31 #include <map>
32 #include <stdint.h>
34 namespace Barry {
36 // forward declarations
37 class IConverter;
40 // NOTE: All classes here must be container-safe! Perhaps add sorting
41 // operators in the future.
45 /// \addtogroup RecordParserClasses
46 /// @{
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
52 public:
53 typedef Barry::UnknownsType UnknownsType;
55 uint8_t Format;
57 UnknownsType Unknowns;
59 public:
60 const unsigned char* ParseField(const unsigned char *begin,
61 const unsigned char *end, const IConverter *ic = 0);
63 public:
64 ServiceBookConfig();
65 ~ServiceBookConfig();
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;
74 void Clear();
76 void Dump(std::ostream &os) const;
79 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const ServiceBookConfig &msg) {
80 msg.Dump(os);
81 return os;
85 class ServiceBookData;
87 class BXEXPORT ServiceBook
89 ServiceBookData *m_data;
91 public:
92 typedef std::vector<UnknownField> UnknownsType;
94 uint8_t RecType;
95 uint32_t RecordId;
96 std::string Name;
97 std::string HiddenName;
98 std::string Description;
99 std::string DSID;
100 std::string BesDomain;
101 std::string UniqueId;
102 std::string ContentId;
103 ServiceBookConfig Config;
105 UnknownsType Unknowns;
107 public:
108 const unsigned char* ParseField(const unsigned char *begin,
109 const unsigned char *end, const IConverter *ic = 0);
111 public:
112 ServiceBook();
113 ~ServiceBook();
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)
126 void Clear();
127 void Dump(std::ostream &os) const;
128 std::string GetDescription() const;
130 // sorting
131 bool operator<(const ServiceBook &other) const;
133 // database name
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) {
142 msg.Dump(os);
143 return os;
146 /// @}
148 } // namespace Barry
150 #endif