# r_cstore.h

Go to the documentation of this file.

    00001 ///
    00002 /// \file       r_cstore.h
    00003 ///             Blackberry database record parser class for
    00004 ///             Content Store records.
    00005 ///
    00006
    00007 /*
    00008     Copyright (C) 2010-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_CSTORE_H__
    00024 #define __BARRY_RECORD_CSTORE_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 /// \addtogroup RecordParserClasses
    00045 /// @{
    00046
    00047 //
    00048 // Content Store record class
    00049 //
    00050 /// Represents a single record in the Content Store Blackberry database.
    00051 ///
    00052 class BXEXPORT ContentStore
    00053 {
    00054 public:
    00055         typedef Barry::UnknownsType             UnknownsType;
    00056
    00057         //
    00058         // Record fields
    00059         //
    00060
    00061         // contact specific data
    00062         uint8_t RecType;
    00063         uint32_t RecordId;
    00064
    00065         std::string Filename;
    00066         bool FolderFlag;
    00067         std::string FileContent;
    00068         std::string FileDescriptor;
    00069
    00070         UnknownsType Unknowns;
    00071
    00072 private:
    00073         uint64_t FileSize;
    00074
    00075 public:
    00076         const unsigned char* ParseField(const unsigned char *begin,
    00077                 const unsigned char *end, const IConverter *ic = 0);
    00078
    00079 public:
    00080         ContentStore();
    00081         ~ContentStore();
    00082
    00083         // operations (common among record classes)
    00084         void Clear();                   // erase everything
    00085         void Dump(std::ostream &os) const;
    00086         std::string GetDescription() const;
    00087
    00088         // Sorting - use enough data to make the sorting as
    00089         //           consistent as possible
    00090         bool operator<(const ContentStore &other) const;
    00091
    00092         // Parser / Builder API (see parser.h / builder.h)
    00093         uint8_t GetRecType() const { return RecType; }
    00094         uint32_t GetUniqueId() const { return RecordId; }
    00095         void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; }
    00096         void ParseHeader(const Data &data, size_t &offset);
    00097         void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0);
    00098         void BuildHeader(Data &data, size_t &offset) const;
    00099         void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const;
    00100         static const char * GetDBName() { return "Content Store"; }
    00101         static uint8_t GetDefaultRecType() { return 0; }
    00102 };
    00103
    00104 BXEXPORT inline std::ostream& operator<< (std::ostream &os,
    00105                                         const ContentStore &cstore)
    00106 {
    00107         cstore.Dump(os);
    00108         return os;
    00109 }
    00110
    00111 /// @}
    00112
    00113 } // namespace Barry
    00114
    00115 #endif
    00116