| Disk ARchive 2.8.4 Full featured and portable backup and archiving tool

Loading...
Searching...
No Matches
label.hpp
Go to the documentation of this file.
1/*********************************************************************/
2// dar - disk archive - a backup/restoration program
3// Copyright (C) 2002-2026 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18//
19// to contact the author, see the AUTHOR file
20/*********************************************************************/
21
25
26#ifndef LABEL_HPP
27#define LABEL_HPP
28
29#include "../my_config.h"
30
31#include "integers.hpp"
32#include "generic_file.hpp"
33
34 namespace libdar
35{
36
39
41
42 class label
43 {
44 public:
45 label(); // builds a label equal to 'zero'
46 label(const label & ref) { copy_from(ref); };
47 label(label && ref) noexcept { move_from(std::move(ref)); };
48 label & operator = (const label & ref) { copy_from(ref); return *this; };
49 label & operator = (label && ref) noexcept { move_from(std::move(ref)); return *this; };
50 ~label() = default;
51
52 bool operator == (const label & ref) const;
53 bool operator != (const label & ref) const { return ! ((*this) == ref); };
54
55 void clear();
56 bool is_cleared() const;
57
58 void generate_internal_filename();
59
60 void read(generic_file & f);
61 void dump(generic_file & f) const;
62
63 void invert_first_byte() { val[0] = ~val[0]; };
64
65 // avoid using these two calls, only here for backward compatibility
66 // where the cost to move to object is really too heavy than
67 // sticking with a char array.
68 U_I size() const { return LABEL_SIZE; };
69 char *data() { return (char *)&val; };
70 const char *data() const { return (char *)&val; };
71
72 static U_I common_size() { return LABEL_SIZE; };
73
74 private:
75 static constexpr U_I LABEL_SIZE = 10;
76
77 char val[LABEL_SIZE];
78
79 void copy_from(const label & ref);
80 void move_from(label && ref) noexcept;
81 };
82
83
84 extern const label label_zero;
85
87
88} // end of namespace
89
90#endif
libdar::generic_file
this is the interface class from which all other data transfer classes inherit
Definition generic_file.hpp:77
libdar::label
manage label data structure used in archive slice headers
Definition label.hpp:43
generic_file.hpp
class generic_file is defined here as well as class fichier
integers.hpp
are defined here basic integer types that tend to be portable
my_config.h
include macro defined by the configure script and some specific additional ones
libdar
libdar namespace encapsulate all libdar symbols
Definition archive.hpp:47