1 // Written by Thorsten Brehm, started November 2012. 2 // 3 // Copyright (C) 2012 Thorsten Brehm, brehmt at gmail dt com 4 // 5 // This library is free software; you can redistribute it and/or 6 // modify it under the terms of the GNU Library General Public 7 // License as published by the Free Software Foundation; either 8 // version 2 of the License, or (at your option) any later version. 9 // 10 // This library is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 // Library General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program; if not, write to the Free Software 17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 // 19 // $Id$ 20 21 #ifndef GZ_CONTAINER_FILE_HXX 22 #define GZ_CONTAINER_FILE_HXX 23 24 #include <string> 25 #include <simgear/io/iostreams/sgstream.hxx> 26 27 class SGPropertyNode; 28 29 namespace simgear 30 { 31 32 typedef int ContainerType; 33 34 /** A class to write container files. */ 35 class gzContainerReader : public sg_gzifstream 36 { 37 public: 38 gzContainerReader( const SGPath& name, 39 const std::string& fileMagic); 40 41 bool readContainerHeader(ContainerType* pType, size_t* pSize); 42 bool readContainer(ContainerType* pType, char** ppData, size_t* pSize); 43 private: 44 std::string filename; 45 }; 46 47 /** A class to read container files. */ 48 class gzContainerWriter : public sg_gzofstream 49 { 50 public: 51 gzContainerWriter( const SGPath& name, 52 const std::string& fileMagic); 53 54 bool writeContainerHeader(ContainerType Type, size_t Size); 55 bool writeContainer(ContainerType Type, const char* pData, size_t Size); 56 bool writeContainer(ContainerType Type, const char* stringBuffer); 57 bool writeContainer(ContainerType Type, SGPropertyNode* root); 58 private: 59 std::string filename; 60 }; 61 62 } 63 64 #endif // GZ_CONTAINER_FILE_HXX 65