• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MikkelSchubert / adapterremoval / #45

20 Sep 2024 06:49PM UTC coverage: 26.244% (-49.2%) from 75.443%
#45

push

travis-ci

web-flow
attempt to fix coveralls run

2458 of 9366 relevant lines covered (26.24%)

4362.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/linereader_joined.hpp
1
/*************************************************************************\
2
 * AdapterRemoval - cleaning next-generation sequencing reads            *
3
 *                                                                       *
4
 * Copyright (C) 2017 by Mikkel Schubert - mikkelsch@gmail.com           *
5
 *                                                                       *
6
 * This program is free software: you can redistribute it and/or modify  *
7
 * it under the terms of the GNU General Public License as published by  *
8
 * the Free Software Foundation, either version 3 of the License, or     *
9
 * (at your option) any later version.                                   *
10
 *                                                                       *
11
 * This program is distributed in the hope that it will be useful,       *
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
 * GNU General Public License for more details.                          *
15
 *                                                                       *
16
 * You should have received a copy of the GNU General Public License     *
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>. *
18
\*************************************************************************/
19
#pragma once
20

21
#include "commontypes.hpp" // for string_vec
22
#include "linereader.hpp"  // for line_reader_base
23
#include <cstddef>         // for size_t
24
#include <memory>          // for unique_ptr
25
#include <string>          // for string
26

27
namespace adapterremoval {
28

29
/**
30
 * Multi-file line-reader
31
 *
32
 * Wrapper around line_reader that automatically reads through one or more
33
 * files, returning the content as a contiguous stream of lines. No assumptions
34
 * are made about the format of the individual files.
35
 */
36
class joined_line_readers : public line_reader_base
37
{
38
public:
39
  /** Creates line-reader over multiple files in the specified order. */
40
  explicit joined_line_readers(const string_vec& filenames);
41

42
  /**
43
   * Reads a line from the currently open file; if EOF is encountered, the
44
   * currently open file is closed and the next file is opened. Returns true
45
   * if a line was successfully read, or false if no files remain.
46
   */
47
  bool getline(std::string& dst) override;
48

49
  /** Currently open file; empty if no file is open. */
50
  const std::string& filename() const { return m_filename; }
×
51

52
  /** Line number in the current file (1-based); 0 if no file is open. */
53
  size_t linenumber() const { return m_current_line; }
×
54

55
  joined_line_readers(const joined_line_readers&) = delete;
56
  joined_line_readers(joined_line_readers&&) = delete;
57
  joined_line_readers& operator=(const joined_line_readers&) = delete;
58
  joined_line_readers& operator=(joined_line_readers&&) = delete;
59

60
private:
61
  /**
62
   * Open the next file, removes it from the queue, and returns true; returns
63
   * false if no files remain to be processed.
64
   */
65
  bool open_next_file();
66

67
  //! Files left to read; stored in reverse order.
68
  string_vec m_filenames{};
69
  //! Currently open file, if any.
70
  std::unique_ptr<line_reader> m_reader{};
71
  //! The currently open file
72
  std::string m_filename{};
73
  //! Current line across all files.
74
  size_t m_current_line = 0;
75
};
76

77
} // namespace adapterremoval
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc