RBHeader.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libe-book project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * For further information visit http://libebook.sourceforge.net
00008  */
00009 
00010 #ifndef RBHEADER_H_INCLUDED
00011 #define RBHEADER_H_INCLUDED
00012 
00013 #include <deque>
00014 #include <string>
00015 
00016 #include "libebook_utils.h"
00017 
00018 namespace libebook
00019 {
00020 
00021 class RBHeader
00022 {
00023 public:
00024   enum Flag
00025   {
00026     FLAG_ENCRYPTED = 1,
00027     FLAG_INFO_PAGE = 1 << 1,
00028     FLAG_RESERVED = 1 << 2,
00029     FLAG_DEFLATED = 1 << 3
00030   };
00031 
00032   struct Entry
00033   {
00034     std::string name;
00035     unsigned length;
00036     unsigned offset;
00037     unsigned flags;
00038 
00039     Entry();
00040   };
00041 
00042   typedef std::deque<Entry> Directory_t;
00043 
00044 public:
00045   explicit RBHeader(const RVNGInputStreamPtr_t &input);
00046 
00047   unsigned getInfoID() const;
00048   const Directory_t &getDirectory() const;
00049 
00050 private:
00051   void readHeader(const RVNGInputStreamPtr_t &input);
00052   void readDirectory(const RVNGInputStreamPtr_t &input);
00053 
00054 private:
00055   unsigned m_version;
00056   unsigned m_tocOffset;
00057   unsigned m_length;
00058   Directory_t m_dir;
00059   unsigned m_info;
00060 };
00061 
00062 }
00063 
00064 #endif // RBHEADER_H_INCLUDED
00065 
00066 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */