Disk ARchive  2.4.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
string_file.hpp
Go to the documentation of this file.
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 // $Id$
00022 //
00023 /*********************************************************************/
00024 //
00025 
00029 
00030 #ifndef STRING_FILE_HPP
00031 #define STRING_FILE_HPP
00032 
00033 #include "../my_config.h"
00034 #include "infinint.hpp"
00035 #include "generic_file.hpp"
00036 #include "integers.hpp"
00037 #include "erreurs.hpp"
00038 
00039 namespace libdar
00040 {
00041 
00043 
00045     class string_file : public generic_file
00046     {
00047     public:
00048 
00050         string_file(const std::string & contents): generic_file(gf_read_only) { data = contents; cur = 0; len = data.size(); };
00051 
00052             // inherited from generic_file
00053         bool skip(const infinint & pos);
00054         bool skip_to_eof() { cur = len; return true; };
00055         bool skip_relative(S_I x);
00056         infinint get_position() { return cur; };
00057 
00058 #ifdef LIBDAR_SPECIAL_ALLOC
00059         USE_SPECIAL_ALLOC(string_file);
00060 #endif
00061     protected:
00062             // inherited from generic_file
00063         U_I inherited_read(char *a, U_I size);
00064         void inherited_write(const char *a, U_I size) { throw Efeature("Writing on a string_file is not allowed"); };
00065         void inherited_sync_write() {};
00066         void inherited_terminate() {};
00067 
00068     private:
00069         std::string data;
00070         infinint cur;
00071         infinint len;
00072     };
00073 
00074 } // end of namespace
00075 
00076 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines