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 <map>
27
28
namespace
ept
{
29
namespace
debtags {
30
31
/*
32
class DebDBConsumer
33
{
34
public:
35
virtual void consumeField(const std::string& name, const std::string& val) throw () = 0;
36
virtual void consumeEndOfRecord() throw () = 0;
37
};
38
*/
39
43
class
DebDBParser
44
{
45
protected
:
46
FILE*
in
;
47
std::string
pathname
;
48
bool
isBOL
;
49
bool
isEOF
;
50
51
// Eat spaces and empty lines
52
// Returns the number of '\n' encountered
53
int
eatSpacesAndEmptyLines
();
54
55
// Get the ^([A-Za-z0-9]+) field name
56
std::string
getFieldName
();
57
58
// Eat the \s*: characters that divide the field name and the field
59
// data
60
void
eatFieldSep
();
61
62
// Get the \s*(.+?)\s*\n of a body line
63
void
appendFieldBody
(std::string& body);
64
65
public
:
66
typedef
std::map<std::string, std::string>
Record
;
67
68
DebDBParser
(FILE* input,
const
std::string& pathname);
69
70
const
std::string&
fileName
()
const
throw () {
return
pathname
; }
71
72
// Read a record and positions itself at the start of the next one
73
// Returns false when there are no more records available
74
bool
nextRecord
(Record& rec);
75
};
76
77
}
78
}
79
80
// vim:set ts=4 sw=4:
81
#endif
ept::debtags::DebDBParser::in
FILE * in
Definition:
debdbparser.h:46
ept::debtags::DebDBParser::isBOL
bool isBOL
Definition:
debdbparser.h:48
ept::debtags::DebDBParser
Parse Debian records from a parser input.
Definition:
debdbparser.h:43
ept
String functions.
Definition:
apt.cc:38
ept::debtags::DebDBParser::eatSpacesAndEmptyLines
int eatSpacesAndEmptyLines()
Definition:
debdbparser.cc:31
ept::debtags::DebDBParser::pathname
std::string pathname
Definition:
debdbparser.h:47
ept::debtags::DebDBParser::Record
std::map< std::string, std::string > Record
Definition:
debdbparser.h:66
ept::debtags::DebDBParser::fileName
const std::string & fileName() const
Definition:
debdbparser.h:70
ept::debtags::DebDBParser::appendFieldBody
void appendFieldBody(std::string &body)
Definition:
debdbparser.cc:105
ept::debtags::DebDBParser::nextRecord
bool nextRecord(Record &rec)
Definition:
debdbparser.cc:146
ept::debtags::DebDBParser::DebDBParser
DebDBParser(FILE *input, const std::string &pathname)
Definition:
debdbparser.cc:136
ept::debtags::DebDBParser::isEOF
bool isEOF
Definition:
debdbparser.h:49
ept::debtags::DebDBParser::eatFieldSep
void eatFieldSep()
Definition:
debdbparser.cc:83
ept::debtags::DebDBParser::getFieldName
std::string getFieldName()
Definition:
debdbparser.cc:57
Generated by
1.8.13