Disk ARchive  2.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
label.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2052 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program 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
13 // GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21 // $Id: label.hpp,v 1.6 2011/04/17 16:36:36 edrusb Rel $
22 //
23 /*********************************************************************/
24 
28 
29 #ifndef LABEL_HPP
30 #define LABEL_HPP
31 
32 #include "../my_config.h"
33 
34 #include "integers.hpp"
35 #include "generic_file.hpp"
36 
37 namespace libdar
38 {
39 
42 
43  class label
44  {
45  public:
46  label(); // builds a label equal to 'zero'
47  label(const label & ref) { copy_from(ref); };
48  const label & operator = (const label & ref) { copy_from(ref); return *this; };
49 
50  bool operator == (const label & ref) const;
51  bool operator != (const label & ref) const { return ! ((*this) == ref); };
52 
53  void clear();
54  bool is_cleared() const;
55 
56  void generate_internal_filename();
57 
58  void read(generic_file & f);
59  void dump(generic_file & f) const;
60 
61  void invert_first_byte() { val[0] = ~val[0]; };
62 
63  // avoid using these two calls, only here for backward compatibility
64  // where the cost to move to object is really too heavy than
65  // sticking with an char array.
66  U_I size() const { return LABEL_SIZE; };
67  char *data() { return (char *)&val; };
68  const char *data() const { return (char *)&val; };
69 
70  static U_I common_size() { return LABEL_SIZE; };
71 
72  private:
73  static const U_I LABEL_SIZE = 10;
74 
75  char val[LABEL_SIZE];
76 
77  void copy_from(const label & ref);
78  };
79 
80 
81  extern const label label_zero;
82 
84 
85 } // end of namespace
86 
87 #endif