gui: added "restored" notify message during restore
[barry.git] / src / r_servicebook.h
blob68d94be3211a0cd5c61389f869a920ece6fbcc9d
1 ///
2 /// \file r_servicebook.h
3 /// Blackberry database record parser class for the
4 /// Service Book record.
5 ///
7 /*
8 Copyright (C) 2005-2010, 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 std::vector<UnknownField> 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 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;
73 void Clear();
75 void Dump(std::ostream &os) const;
78 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const ServiceBookConfig &msg) {
79 msg.Dump(os);
80 return os;
84 class ServiceBookData;
86 class BXEXPORT ServiceBook
88 ServiceBookData *m_data;
90 public:
91 typedef std::vector<UnknownField> UnknownsType;
93 uint8_t RecType;
94 uint32_t RecordId;
95 std::string Name;
96 std::string HiddenName;
97 std::string Description;
98 std::string DSID;
99 std::string BesDomain;
100 std::string UniqueId;
101 std::string ContentId;
102 ServiceBookConfig Config;
104 UnknownsType Unknowns;
106 public:
107 const unsigned char* ParseField(const unsigned char *begin,
108 const unsigned char *end, const IConverter *ic = 0);
110 public:
111 ServiceBook();
112 ~ServiceBook();
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 void Clear();
125 void Dump(std::ostream &os) const;
127 // sorting
128 bool operator<(const ServiceBook &other) const { return RecordId < RecordId; }
130 // database name
131 static const char * GetDBName() { return "Service Book"; }
132 static uint8_t GetDefaultRecType() { return 0; }
135 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const ServiceBook &msg) {
136 msg.Dump(os);
137 return os;
140 /// @}
142 } // namespace Barry
144 #endif