r_servicebook.h

Go to the documentation of this file.
00001 ///
00002 /// \file       r_servicebook.h
00003 ///             Blackberry database record parser class for the
00004 ///             Service Book record.
00005 ///
00006 
00007 /*
00008     Copyright (C) 2005-2008, Net Direct Inc. (http://www.netdirect.ca/)
00009 
00010     This program is free software; you can redistribute it and/or modify
00011     it under the terms of the GNU General Public License as published by
00012     the Free Software Foundation; either version 2 of the License, or
00013     (at your option) any later version.
00014 
00015     This program is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00018 
00019     See the GNU General Public License in the COPYING file at the
00020     root directory of this project for more details.
00021 */
00022 
00023 #ifndef __BARRY_RECORD_SERVICEBOOK_H__
00024 #define __BARRY_RECORD_SERVICEBOOK_H__
00025 
00026 #include "dll.h"
00027 #include "record.h"
00028 #include <iosfwd>
00029 #include <string>
00030 #include <vector>
00031 #include <map>
00032 #include <stdint.h>
00033 
00034 namespace Barry {
00035 
00036 //
00037 // NOTE:  All classes here must be container-safe!  Perhaps add sorting
00038 //        operators in the future.
00039 //
00040 
00041 
00042 /// \addtogroup RecordParserClasses
00043 /// @{
00044 
00045 // This is a packed field, which is a group of fields packed in
00046 // variable length records inside one larger field of a normal record.
00047 class BXEXPORT ServiceBookConfig
00048 {
00049 public:
00050         typedef std::vector<UnknownField>               UnknownsType;
00051 
00052         uint8_t Format;
00053 
00054         UnknownsType Unknowns;
00055 
00056 public:
00057         const unsigned char* ParseField(const unsigned char *begin,
00058                 const unsigned char *end);
00059 
00060 public:
00061         ServiceBookConfig();
00062         ~ServiceBookConfig();
00063 
00064         // Parser / Builder API (see parser.h / builder.h)
00065         void ParseHeader(const Data &data, size_t &offset);
00066         void ParseFields(const Data &data, size_t &offset);
00067         void BuildHeader(Data &data, size_t &offset) const;
00068         void BuildFields(Data &data, size_t &offset) const;
00069 
00070         void Clear();
00071 
00072         void Dump(std::ostream &os) const;
00073 };
00074 
00075 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const ServiceBookConfig &msg) {
00076         msg.Dump(os);
00077         return os;
00078 }
00079 
00080 
00081 class BXEXPORT ServiceBook
00082 {
00083         int NameType, DescType, UniqueIdType;
00084 
00085 public:
00086         typedef std::vector<UnknownField>               UnknownsType;
00087 
00088         uint8_t RecType;
00089         uint32_t RecordId;
00090         std::string Name;
00091         std::string HiddenName;
00092         std::string Description;
00093         std::string DSID;
00094         std::string BesDomain;
00095         std::string UniqueId;
00096         std::string ContentId;
00097         ServiceBookConfig Config;
00098 
00099         UnknownsType Unknowns;
00100 
00101 public:
00102         const unsigned char* ParseField(const unsigned char *begin,
00103                 const unsigned char *end);
00104 
00105 public:
00106         ServiceBook();
00107         ~ServiceBook();
00108 
00109         // Parser / Builder API (see parser.h / builder.h)
00110         uint8_t GetRecType() const { return RecType; }
00111         uint32_t GetUniqueId() const { return RecordId; }
00112         void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; }
00113         void ParseHeader(const Data &data, size_t &offset);
00114         void ParseFields(const Data &data, size_t &offset);
00115         void BuildHeader(Data &data, size_t &offset) const;
00116         void BuildFields(Data &data, size_t &offset) const;
00117 
00118         void Clear();
00119 
00120         void Dump(std::ostream &os) const;
00121 
00122         // sorting
00123         bool operator<(const ServiceBook &other) const { return RecordId < RecordId; }
00124 
00125         // database name
00126         static const char * GetDBName() { return "Service Book"; }
00127         static uint8_t GetDefaultRecType() { return 0; }
00128 };
00129 
00130 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const ServiceBook &msg) {
00131         msg.Dump(os);
00132         return os;
00133 }
00134 
00135 /// @}
00136 
00137 } // namespace Barry
00138 
00139 #endif
00140 

Generated on Wed Sep 24 21:27:32 2008 for Barry by  doxygen 1.5.1