r_folder.h

Go to the documentation of this file.
00001 ///
00002 /// \file       r_folder.h
00003 ///             Record parsing class for the Folder database.
00004 ///
00005 
00006 /*
00007     Copyright (C) 2005-2010, Net Direct Inc. (http://www.netdirect.ca/)
00008     Copyright (C) 2007, Brian Edginton
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_FOLDER_H__
00024 #define __BARRY_RECORD_FOLDER_H__
00025 
00026 #include "dll.h"
00027 #include "record.h"
00028 #include <vector>
00029 #include <string>
00030 #include <stdint.h>
00031 
00032 namespace Barry {
00033 
00034 // forward declarations
00035 class IConverter;
00036 
00037 class BXEXPORT Folder
00038 {
00039 public:
00040         typedef std::vector<UnknownField>                       UnknownsType;
00041         uint8_t RecType;
00042         uint32_t RecordId;
00043 
00044         std::string Name;
00045         uint16_t Number;        // Not unique, used for ordering of subfolders - NOT level
00046         uint16_t Level; // From parent
00047 
00048         enum FolderType {
00049                 FolderSubtree = 0,
00050                 FolderDeleted,
00051                 FolderInbox,
00052                 FolderOutbox,
00053                 FolderSent,
00054                 FolderOther,
00055                 FolderDraft = 0x0a
00056         };
00057         FolderType Type;
00058 
00059         enum FolderStatusType {
00060                 FolderOrphan = 0x50,
00061                 FolderUnfiled,
00062                 FolderFiled
00063         };
00064 
00065         UnknownsType Unknowns;
00066 
00067 protected:
00068         static FolderType TypeProto2Rec(uint8_t t);
00069         static uint8_t TypeRec2Proto(FolderType t);
00070 
00071 public:
00072         Folder();
00073         ~Folder();
00074 
00075         const unsigned char* ParseField(const unsigned char *begin,
00076                 const unsigned char *end, const IConverter *ic = 0);
00077         uint8_t GetRecType() const { return RecType; }
00078         uint32_t GetUniqueId() const { return RecordId; }
00079         void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; }
00080         void ParseHeader(const Data &data, size_t &offset);
00081         void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0);
00082         void BuildHeader(Data &data, size_t &offset) const;
00083 
00084         void Clear();
00085 
00086         void Dump(std::ostream &os) const;
00087         bool operator<(const Folder &other) const { return Name < other.Name; }
00088 
00089         // database name
00090         static const char * GetDBName() { return "Folders"; }
00091         static uint8_t GetDefaultRecType() { return 0; }
00092 
00093 };
00094 
00095 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Folder &msg) {
00096         msg.Dump(os);
00097         return os;
00098 }
00099 
00100 } // namespace Barry
00101 
00102 #endif  // __BARRY_RECORD_FOLDER_H__
00103 
00104 

Generated on 29 Mar 2010 for Barry by  doxygen 1.6.1