Disk ARchive: eols.hpp Source File

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

Loading...
Searching...
No Matches
eols.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
28
29#ifndef EOLS_HPP
30#define EOLS_HPP
31
32#include "../my_config.h"
33
34#include <string>
35#include <deque>
36
37#include "integers.hpp"
38
39namespace libdar
40{
41
44
46
47 class eols
48 {
49 public:
50 eols(const std::deque<std::string> & end_sequences);
51
52 eols(const eols & ref) { copy_from(ref); };
53 eols(eols && ref) noexcept = default;
54 eols & operator = (const eols & ref) { copy_from(ref); return *this; };
55 eols & operator = (eols && ref) = default;
56 ~eols() = default;
57
59 void add_sequence(const std::string & seq);
60
62 void reset_detection() const;
63
65
78 bool eol_reached(char next_read_byte,
79 U_I & eol_sequence_length,
80 U_I & after_eol_read_bytes) const;
81
82 private:
83 class in_progress
84 {
85 public:
86 in_progress(const std::string & val): ref(val) { reset(); };
87
88 // methods
89 void reset() const { next_to_match = ref.begin(); bypass = false; passed = 0; larger = false; };
90 bool match(char next_read_byte) const;
91 U_I progression() const;
92 bool set_bypass(U_I prog) const;
93 void set_larger() const { larger = true; };
94 bool has_matched() const { return next_to_match == ref.end(); };
95
96 // fields
97 std::string ref;
98 mutable std::string::const_iterator next_to_match;
99 mutable bool bypass;
100 mutable U_I passed;
101 mutable bool larger;
102 };
103
104 std::deque<in_progress> eols_curs;
105 mutable U_I ref_progression;
106
108
110 bool bypass_or_larger(U_I prog) const;
111 bool all_bypassed_or_matched() const;
112 bool find_larger_match(U_I & seq_length, U_I & read_after_eol) const;
113 void copy_from(const eols & ref);
114 };
115
117
118} // end of namespace
119
120#endif
libdar::eols::bypass_or_larger
bool bypass_or_larger(U_I prog) const
set bypass flag for all in_progress of eols_curs that progression is less than or equal 'prog'
libdar::eols::add_sequence
void add_sequence(const std::string &seq)
add a new sequence for End of Line
libdar::eols::reset_detection
void reset_detection() const
reset the detection to be beginning of each EOL sequence
libdar::eols::eol_reached
bool eol_reached(char next_read_byte, U_I &eol_sequence_length, U_I &after_eol_read_bytes) const
check whether we have reach an end of line
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