# 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-2011, 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 // forward declarations
    00037 class IConverter;
    00038
    00039 //
    00040 // NOTE:  All classes here must be container-safe!  Perhaps add sorting
    00041 //        operators in the future.
    00042 //
    00043
    00044
    00045 /// \addtogroup RecordParserClasses
    00046 /// @{
    00047
    00048 // This is a packed field, which is a group of fields packed in
    00049 // variable length records inside one larger field of a normal record.
    00050 class BXEXPORT ServiceBookConfig
    00051 {
    00052 public:
    00053         typedef Barry::UnknownsType                     UnknownsType;
    00054
    00055         uint8_t Format;
    00056
    00057         UnknownsType Unknowns;
    00058
    00059 public:
    00060         const unsigned char* ParseField(const unsigned char *begin,
    00061                 const unsigned char *end, const IConverter *ic = 0);
    00062
    00063 public:
    00064         ServiceBookConfig();
    00065         ~ServiceBookConfig();
    00066
    00067         // Parser / Builder API (see parser.h / builder.h)
    00068         void ParseHeader(const Data &data, size_t &offset);
    00069         void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0);
    00070         void BuildHeader(Data &data, size_t &offset) const;
    00071         void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const;
    00072
    00073         void Clear();
    00074
    00075         void Dump(std::ostream &os) const;
    00076 };
    00077
    00078 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const ServiceBookConfig &msg) {
    00079         msg.Dump(os);
    00080         return os;
    00081 }
    00082
    00083
    00084 class ServiceBookData;
    00085
    00086 class BXEXPORT ServiceBook
    00087 {
    00088         ServiceBookData *m_data;
    00089
    00090 public:
    00091         typedef std::vector<UnknownField>               UnknownsType;
    00092
    00093         uint8_t RecType;
    00094         uint32_t RecordId;
    00095         std::string Name;
    00096         std::string HiddenName;
    00097         std::string Description;
    00098         std::string DSID;
    00099         std::string BesDomain;
    00100         std::string UniqueId;
    00101         std::string ContentId;
    00102         ServiceBookConfig Config;
    00103
    00104         UnknownsType Unknowns;
    00105
    00106 public:
    00107         const unsigned char* ParseField(const unsigned char *begin,
    00108                 const unsigned char *end, const IConverter *ic = 0);
    00109
    00110 public:
    00111         ServiceBook();
    00112         ~ServiceBook();
    00113
    00114         // Parser / Builder API (see parser.h / builder.h)
    00115         uint8_t GetRecType() const { return RecType; }
    00116         uint32_t GetUniqueId() const { return RecordId; }
    00117         void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; }
    00118         void ParseHeader(const Data &data, size_t &offset);
    00119         void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0);
    00120         void BuildHeader(Data &data, size_t &offset) const;
    00121         void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const;
    00122
    00123         // operations (common among record classes)
    00124         void Clear();
    00125         void Dump(std::ostream &os) const;
    00126         std::string GetDescription() const;
    00127
    00128         // sorting
    00129         bool operator<(const ServiceBook &other) const;
    00130
    00131         // database name
    00132         static const char * GetDBName() { return "Service Book"; }
    00133         static uint8_t GetDefaultRecType() { return 0; }
    00134 };
    00135
    00136 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const ServiceBook &msg) {
    00137         msg.Dump(os);
    00138         return os;
    00139 }
    00140
    00141 /// @}
    00142
    00143 } // namespace Barry
    00144
    00145 #endif
    00146