|
Disk ARchive
2.4.12
|
00001 /*********************************************************************/ 00002 // dar - disk archive - a backup/restoration program 00003 // Copyright (C) 2002-2052 Denis Corbin 00004 // 00005 // This program is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU General Public License 00007 // as published by the Free Software Foundation; either version 2 00008 // of the License, or (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 // 00019 // to contact the author : http://dar.linux.free.fr/email.html 00020 /*********************************************************************/ 00021 00025 00026 #ifndef STRING_FILE_HPP 00027 #define STRING_FILE_HPP 00028 00029 #include "../my_config.h" 00030 #include "infinint.hpp" 00031 #include "generic_file.hpp" 00032 #include "integers.hpp" 00033 #include "erreurs.hpp" 00034 00035 namespace libdar 00036 { 00037 00039 00041 class string_file : public generic_file 00042 { 00043 public: 00044 00046 string_file(const std::string & contents): generic_file(gf_read_only) { data = contents; cur = 0; len = data.size(); }; 00047 00048 // inherited from generic_file 00049 bool skip(const infinint & pos); 00050 bool skip_to_eof() { cur = len; return true; }; 00051 bool skip_relative(S_I x); 00052 infinint get_position() { return cur; }; 00053 00054 #ifdef LIBDAR_SPECIAL_ALLOC 00055 USE_SPECIAL_ALLOC(string_file); 00056 #endif 00057 protected: 00058 // inherited from generic_file 00059 U_I inherited_read(char *a, U_I size); 00060 void inherited_write(const char *a, U_I size) { throw Efeature("Writing on a string_file is not allowed"); }; 00061 void inherited_sync_write() {}; 00062 void inherited_terminate() {}; 00063 00064 private: 00065 std::string data; 00066 infinint cur; 00067 infinint len; 00068 }; 00069 00070 } // end of namespace 00071 00072 #endif
1.7.6.1