Disk ARchive 2.7.16
Full featured and portable backup and archiving tool
mem_block.hpp
Go to the documentation of this file.
1/*********************************************************************/
2// dar - disk archive - a backup/restoration program
3// Copyright (C) 2002-2024 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
26
27#ifndef MEM_BLOCK_HPP
28#define MEM_BLOCK_HPP
29
30#include "../my_config.h"
31#include <string>
32
33#include "integers.hpp"
34
35namespace libdar
36{
37
40
41 class mem_block
42 {
43 public:
44 mem_block(U_I size = 0);
45 mem_block(const mem_block & ref) = delete;
46 mem_block(mem_block && ref) noexcept;
47 mem_block & operator = (const mem_block & ref) = delete;
48 mem_block & operator = (mem_block && ref) noexcept;
49 virtual ~mem_block();
50
51
52 void resize(U_I size);
53
54 U_I read(char *a, U_I size);
55 U_I write(const char *a, U_I size);
56 void rewind_read(U_I offset = 0);
57 void reset() { data_size = 0; read_cursor = 0; write_cursor = 0; };
58 U_I get_max_size() const { return alloc_size; };
59 U_I get_data_size() const { return data_size; };
60 U_I get_read_offset() const { return read_cursor; };
61 bool all_is_read() const { return read_cursor == data_size; };
62 bool is_full() const { return data_size == alloc_size; };
63 bool is_empty() const { return data_size == 0; };
64
65 char* get_addr() { return data; };
66 void set_data_size(U_I size);
67
68 private:
69 char* data;
70 U_I alloc_size;
71 U_I data_size;
72 U_I read_cursor;
73 U_I write_cursor;
74
75 void move_from(mem_block && ref);
76 };
77
78
80
81} // end of namespace
82
83#endif
are defined here basic integer types that tend to be portable
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47