Debian Codegraph @

src/output.h

raw symbols SCIP
1 /***************************************************************************
2 * Copyright (C) 2011-2023 by Hans-Peter Deifel *
3 * [email protected] *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (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 *
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
18 * Boston, MA 02110-1301 USA. *
19 ***************************************************************************/
20
21 #ifndef OUTPUT_H
22 #define OUTPUT_H
23
24 #include <sys/types.h>
25 #include <string>
26 #include "pdfgrep.h"
27
28 struct context {
29 const std::string& filename;
30 size_t pagenum;
31 std::string page_label;
32
33 const Outconf& out;
34 };
35
36 struct match {
37 const std::string string;
38 size_t start;
39 size_t end;
40 };
41
42 /* print the line prefix followed only by the match */
43 void print_only_match(const struct context &context, const struct match &match);
44
45 /** print a line with prefix and highlighting for matches.
46 *
47 * 'matches' must not be empty and all entries must begin and end in the same
48 * line.
49 */
50 void print_matches(const context& context, const std::vector<match>& matches);
51
52 /* print the filename, useful for --files-{with-match,without-matches} */
53 void print_only_filename(const Outconf& outconf, const std::string& filename);
54
55 // Print `lines` lines of context before the match. If lines is smaller than 0,
56 // use the value from context.outconf.
57 void print_context_before(const context& context, const match& match, int lines = -1);
58 // Print `lines` lines of context before the match. If lines is smaller than 0,
59 // use the value from context.outconf.
60 void print_context_after(const context& context, const match& match, int lines = -1);
61 void print_context_between(const context& context, const match& match1, const match& match2);
62 void print_context_separator(const Outconf &out);
63
64 // C++ interface:
65
66 // Print to stderr, with "pdfgrep: " as prefix;
67 std::ostream& err();
68
69 std::ostream& line_prefix(const context& context, bool in_context);
70
71 #endif
72
73 /* Local Variables: */
74 /* mode: c++ */
75 /* End: */