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

Loading...
Searching...
No Matches
archive_num.hpp
Go to the documentation of this file.
1/*********************************************************************/
2// dar - disk archive - a backup/restoration program
3// Copyright (C) 2002-2025 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
27#ifndef ARCHIVE_NUM_HPP
28#define ARCHIVE_NUM_HPP
29
30#include "../my_config.h"
31
32#include "integers.hpp"
33#include "erreurs.hpp"
34
35 namespace libdar
36{
37
40
41 // no need to dig into this class from the API
42 class generic_file;
43
45
46 class archive_num
47 {
48 public:
49 archive_num(U_16 arg = 0) { set(arg); };
50 archive_num(const archive_num & ref) = default;
51 archive_num(archive_num && ref) noexcept = default;
52 archive_num & operator = (const archive_num & ref) = default;
53 archive_num & operator = (archive_num && ref) = default;
54 ~archive_num() = default;
55
57
60 operator U_16() const { return val; };
61 U_16 operator = (U_16 arg) { set(arg); return arg; };
62 archive_num & operator++() { set(val+1); return *this; };
63
64 // no need of order operator (<, <=, >, >=, ==, !=)
65 // thanks to the implicit conversion to U_16 defined
66 // above
67
68 void read_from_file(generic_file &f);
69 void write_to_file(generic_file &f) const;
70
71 private:
72 static constexpr U_I val_size = sizeof(U_16);
73 static constexpr U_I MAX = 65534;
74
75 U_16 val;
76
77 inline void set(U_16 arg)
78 {
79 if(arg >= MAX)
80 throw SRC_BUG;
81 val = arg;
82 }
83 };
84
86
87} // end of namespace
88
89#endif
libdar::archive_num
class archive_num stores the position of an archive inside a dar_manager database
Definition archive_num.hpp:47
erreurs.hpp
contains all the excetion class thrown by libdar
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