paludis
Version 3.0.2
The one true package mangler
paludis
util
simple_parser.hh
1
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
2
3
/*
4
* Copyright (c) 2008, 2009, 2010, 2011 Ciaran McCreesh
5
*
6
* This file is part of the Paludis package manager. Paludis is free software;
7
* you can redistribute it and/or modify it under the terms of the GNU General
8
* Public License version 2, as published by the Free Software Foundation.
9
*
10
* Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
11
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13
* details.
14
*
15
* You should have received a copy of the GNU General Public License along with
16
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17
* Place, Suite 330, Boston, MA 02111-1307 USA
18
*/
19
20
#ifndef PALUDIS_GUARD_PALUDIS_UTIL_SIMPLE_PARSER_HH
21
#define PALUDIS_GUARD_PALUDIS_UTIL_SIMPLE_PARSER_HH 1
22
23
#include <
paludis/util/attributes.hh
>
24
#include <
paludis/util/pimp.hh
>
25
#include <paludis/util/simple_parser-fwd.hh>
26
#include <functional>
27
#include <string>
28
29
namespace
paludis
30
{
31
namespace
simple_parser
32
{
33
typedef
std::function<std::string::size_type (
const
std::string &,
const
std::string::size_type)> SimpleParserMatchFunction;
34
35
class
PALUDIS_VISIBLE
SimpleParserExpression
36
{
37
private
:
38
const
SimpleParserMatchFunction _match;
39
40
public
:
41
SimpleParserExpression(
const
SimpleParserMatchFunction &);
42
43
std::string::size_type match(
const
std::string &,
const
std::string::size_type)
const
44
PALUDIS_ATTRIBUTE
((warn_unused_result));
45
};
46
47
SimpleParserExpression
operator& (
const
SimpleParserExpression
&,
const
SimpleParserExpression
&)
48
PALUDIS_VISIBLE
PALUDIS_ATTRIBUTE
((warn_unused_result));
49
50
SimpleParserExpression
operator>> (
const
SimpleParserExpression
&, std::string &)
51
PALUDIS_VISIBLE
PALUDIS_ATTRIBUTE
((warn_unused_result));
52
53
SimpleParserExpression
operator* (
const
SimpleParserExpression
&)
54
PALUDIS_VISIBLE
PALUDIS_ATTRIBUTE
((warn_unused_result));
55
56
SimpleParserExpression
operator+ (
const
SimpleParserExpression
&)
57
PALUDIS_VISIBLE
PALUDIS_ATTRIBUTE
((warn_unused_result));
58
59
SimpleParserExpression
operator- (
const
SimpleParserExpression
&)
60
PALUDIS_VISIBLE
PALUDIS_ATTRIBUTE
((warn_unused_result));
61
62
SimpleParserExpression
exact(
const
std::string &)
63
PALUDIS_VISIBLE
PALUDIS_ATTRIBUTE
((warn_unused_result));
64
65
SimpleParserExpression
exact_ignoring_case(
const
std::string &)
66
PALUDIS_VISIBLE
PALUDIS_ATTRIBUTE
((warn_unused_result));
67
68
SimpleParserExpression
any_of(
const
std::string &)
69
PALUDIS_VISIBLE
PALUDIS_ATTRIBUTE
((warn_unused_result));
70
71
SimpleParserExpression
any_except(
const
std::string &)
72
PALUDIS_VISIBLE
PALUDIS_ATTRIBUTE
((warn_unused_result));
73
}
74
75
class
PALUDIS_VISIBLE
SimpleParser
76
{
77
private
:
78
Pimp<SimpleParser>
_imp;
79
80
public
:
81
SimpleParser(
const
std::string &);
82
~SimpleParser();
83
84
bool
consume(
const
simple_parser::SimpleParserExpression
&)
PALUDIS_ATTRIBUTE
((warn_unused_result));
85
bool
lookahead(
const
simple_parser::SimpleParserExpression
&)
const
PALUDIS_ATTRIBUTE
((warn_unused_result));
86
bool
eof()
const
PALUDIS_ATTRIBUTE
((warn_unused_result));
87
88
std::string::size_type offset()
const
PALUDIS_ATTRIBUTE
((warn_unused_result));
89
unsigned
current_line_number()
const
PALUDIS_ATTRIBUTE
((warn_unused_result));
90
const
std::string text()
const
PALUDIS_ATTRIBUTE
((warn_unused_result));
91
};
92
93
extern
template
class
Pimp<SimpleParser>
;
94
}
95
96
#endif
attributes.hh
paludis::Pimp
Definition
pimp.hh:52
paludis::simple_parser::SimpleParserExpression
Definition
simple_parser.hh:36
PALUDIS_ATTRIBUTE
#define PALUDIS_ATTRIBUTE(x)
Definition
attributes.hh:53
PALUDIS_VISIBLE
#define PALUDIS_VISIBLE
Definition
attributes.hh:59
paludis
Definition
about_metadata-fwd.hh:24
pimp.hh
Generated by
1.18.0