libept
ept
debtags
maint
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
30
namespace
ept
{
31
namespace
debtags {
32
33
/*
34
class DebDBConsumer
35
{
36
public:
37
virtual void consumeField(const std::string& name, const std::string& val) throw () = 0;
38
virtual void consumeEndOfRecord() throw () = 0;
39
};
40
*/
41
45
class
DebDBParser
46
{
47
protected
:
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
55
int
eatSpacesAndEmptyLines
();
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
67
public
:
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
ept::debtags::DebDBParser
Parse Debian records from a parser input.
Definition
debdbparser.h:46
ept::debtags::DebDBParser::eatFieldSep
void eatFieldSep()
Definition
debdbparser.cc:83
ept::debtags::DebDBParser::fileName
const std::string & fileName() const
Definition
debdbparser.h:72
ept::debtags::DebDBParser::appendFieldBody
void appendFieldBody(std::string &body)
Definition
debdbparser.cc:105
ept::debtags::DebDBParser::getFieldName
std::string getFieldName()
Definition
debdbparser.cc:57
ept::debtags::DebDBParser::isEOF
bool isEOF
Definition
debdbparser.h:51
ept::debtags::DebDBParser::Record
std::map< std::string, std::string > Record
Definition
debdbparser.h:68
ept::debtags::DebDBParser::in
FILE * in
Definition
debdbparser.h:48
ept::debtags::DebDBParser::pathname
std::string pathname
Definition
debdbparser.h:49
ept::debtags::DebDBParser::eatSpacesAndEmptyLines
int eatSpacesAndEmptyLines()
Definition
debdbparser.cc:31
ept::debtags::DebDBParser::nextRecord
bool nextRecord(Record &rec)
Definition
debdbparser.cc:146
ept::debtags::DebDBParser::isBOL
bool isBOL
Definition
debdbparser.h:50
ept
String functions.
Definition
apt.cc:40
Generated by
1.9.8