Disk ARchive  2.4.2
label.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: label.hpp,v 1.6 2011/04/17 16:36:36 edrusb Rel $
00022 //
00023 /*********************************************************************/
00024 
00028 
00029 #ifndef LABEL_HPP
00030 #define LABEL_HPP
00031 
00032 #include "../my_config.h"
00033 
00034 #include "integers.hpp"
00035 #include "generic_file.hpp"
00036 
00037 namespace libdar
00038 {
00039 
00042 
00043     class label
00044     {
00045     public:
00046         label(); // builds a label equal to 'zero'
00047         label(const label & ref) { copy_from(ref); };
00048         const label & operator = (const label & ref) { copy_from(ref); return *this; };
00049 
00050         bool operator == (const label & ref) const;
00051         bool operator != (const label & ref) const { return ! ((*this) == ref); };
00052 
00053         void clear();
00054         bool is_cleared() const;
00055 
00056         void generate_internal_filename();
00057 
00058         void read(generic_file & f);
00059         void dump(generic_file & f) const;
00060 
00061         void invert_first_byte() { val[0] = ~val[0]; };
00062 
00063             // avoid using these two calls, only here for backward compatibility
00064             // where the cost to move to object is really too heavy than
00065             // sticking with an char array.
00066         U_I size() const { return LABEL_SIZE; };
00067         char *data() { return (char *)&val; };
00068         const char *data() const { return (char *)&val; };
00069 
00070         static U_I common_size() { return LABEL_SIZE; };
00071 
00072     private:
00073         static const U_I LABEL_SIZE = 10;
00074 
00075         char val[LABEL_SIZE];
00076 
00077         void copy_from(const label & ref);
00078     };
00079 
00080 
00081     extern const label label_zero;
00082 
00084 
00085 } // end of namespace
00086 
00087 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines