libept
debdbparser.h
Go to the documentation of this file.
1#ifndef EPT_DEBTAGS_DEBDBPARSER_H
2#define EPT_DEBTAGS_DEBDBPARSER_H
3
8/*
9 * Copyright (C) 2003--2015 Enrico Zini <enrico@debian.org>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <cstdio>
27#include <map>
28#include <string>
29
30namespace ept {
31namespace debtags {
32
33/*
34class DebDBConsumer
35{
36public:
37 virtual void consumeField(const std::string& name, const std::string& val) throw () = 0;
38 virtual void consumeEndOfRecord() throw () = 0;
39};
40*/
41
46{
47protected:
48 FILE* in;
49 std::string pathname;
50 bool isBOL;
51 bool isEOF;
52
53 // Eat spaces and empty lines
54 // Returns the number of '\n' encountered
56
57 // Get the ^([A-Za-z0-9]+) field name
58 std::string getFieldName();
59
60 // Eat the \s*: characters that divide the field name and the field
61 // data
62 void eatFieldSep();
63
64 // Get the \s*(.+?)\s*\n of a body line
65 void appendFieldBody(std::string& body);
66
67public:
68 typedef std::map<std::string, std::string> Record;
69
70 DebDBParser(FILE* input, const std::string& pathname);
71
72 const std::string& fileName() const throw () { return pathname; }
73
74 // Read a record and positions itself at the start of the next one
75 // Returns false when there are no more records available
76 bool nextRecord(Record& rec);
77};
78
79}
80}
81
82// vim:set ts=4 sw=4:
83#endif
Parse Debian records from a parser input.
Definition debdbparser.h:46
void eatFieldSep()
Definition debdbparser.cc:83
const std::string & fileName() const
Definition debdbparser.h:72
void appendFieldBody(std::string &body)
Definition debdbparser.cc:105
std::string getFieldName()
Definition debdbparser.cc:57
bool isEOF
Definition debdbparser.h:51
std::map< std::string, std::string > Record
Definition debdbparser.h:68
FILE * in
Definition debdbparser.h:48
std::string pathname
Definition debdbparser.h:49
int eatSpacesAndEmptyLines()
Definition debdbparser.cc:31
bool nextRecord(Record &rec)
Definition debdbparser.cc:146
bool isBOL
Definition debdbparser.h:50
String functions.
Definition apt.cc:40