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-2008, 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 class BXEXPORT Folder
00035 {
00036 public:
00037         typedef std::vector<UnknownField>                       UnknownsType;
00038         uint8_t RecType;
00039         uint32_t RecordId;
00040         
00041         std::string FolderName;
00042         uint16_t        FolderNumber;   // Not unique, used for ordering of subfolders - NOT level
00043         uint16_t        FolderLevel;    // From parent
00044         
00045         enum FolderTypeEnum {
00046                 FolderSubtree = 0,
00047                 FolderDeleted,
00048                 FolderInbox,
00049                 FolderOutbox,
00050                 FolderSent,
00051                 FolderOther,
00052                 FolderDraft = 0x0a
00053         };
00054         FolderTypeEnum FolderType;
00055         
00056         enum FolderStatusType {
00057                 FolderOrphan = 0x50,
00058                 FolderUnfiled,
00059                 FolderFiled
00060         };
00061 
00062         UnknownsType Unknowns;
00063 
00064 public: 
00065         Folder();
00066         ~Folder();
00067 
00068         const unsigned char* ParseField(const unsigned char *begin,
00069                 const unsigned char *end);      
00070         uint8_t GetRecType() const { return RecType; }
00071         uint32_t GetUniqueId() const { return RecordId; }
00072         void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; }
00073         void ParseHeader(const Data &data, size_t &offset);
00074         void ParseFields(const Data &data, size_t &offset);
00075         void BuildHeader(Data &data, size_t &offset) const;
00076 
00077         void Clear();
00078 
00079         void Dump(std::ostream &os) const;
00080         bool operator<(const Folder &other) const { return FolderName < other.FolderName; }
00081 
00082         // database name
00083         static const char * GetDBName() { return "Folders"; }
00084         static uint8_t GetDefaultRecType() { return 0; }
00085 
00086 };
00087 
00088 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Folder &msg) {
00089         msg.Dump(os);
00090         return os;
00091 }
00092 
00093 } // namespace Barry
00094 
00095 #endif  // __BARRY_RECORD_FOLDER_H__
00096 
00097 

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