Loading...
Searching...
No Matches
eols.hpp
Go to the documentation of this file.
/*********************************************************************/
// dar - disk archive - a backup/restoration program
// Copyright (C) 2002-2026 Denis Corbin
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// to contact the author, see the AUTHOR file
/*********************************************************************/
#ifndef EOLS_HPP
#define EOLS_HPP
#include "../my_config.h"
#include <string>
#include <deque>
#include "integers.hpp"
namespace libdar
{
class eols
{
public:
eols(const std::deque<std::string> & end_sequences);
eols(const eols & ref) { copy_from(ref); };
eols(eols && ref) noexcept = default;
eols & operator = (const eols & ref) { copy_from(ref); return *this; };
eols & operator = (eols && ref) = default;
~eols() = default;
void add_sequence(const std::string & seq);
void reset_detection() const;
bool eol_reached(char next_read_byte,
U_I & eol_sequence_length,
U_I & after_eol_read_bytes) const;
private:
class in_progress
{
public:
in_progress(const std::string & val): ref(val) { reset(); };
// methods
void reset() const { next_to_match = ref.begin(); bypass = false; passed = 0; larger = false; };
bool match(char next_read_byte) const;
U_I progression() const;
bool set_bypass(U_I prog) const;
void set_larger() const { larger = true; };
bool has_matched() const { return next_to_match == ref.end(); };
// fields
std::string ref;
mutable std::string::const_iterator next_to_match;
mutable bool bypass;
mutable U_I passed;
mutable bool larger;
};
std::deque<in_progress> eols_curs;
mutable U_I ref_progression;
bool bypass_or_larger(U_I prog) const;
bool all_bypassed_or_matched() const;
bool find_larger_match(U_I & seq_length, U_I & read_after_eol) const;
void copy_from(const eols & ref);
};
} // end of namespace
#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