libnuklei
base
nuklei
Match.h
Go to the documentation of this file.
1
// (C) Copyright Renaud Detry 2007-2015.
2
// Distributed under the GNU General Public License and under the
3
// BSD 3-Clause License (See accompanying file LICENSE.txt).
4
5
/** @file */
6
7
#ifndef NUKLEI_MATCH_H
8
#define NUKLEI_MATCH_H
9
10
#include <string>
11
#include <iostream>
12
#include <stdexcept>
13
#include <
nuklei/Common.h
>
14
15
namespace
nuklei
{
16
17
class
MatchError
:
public
Error
18
{
19
public
:
20
MatchError
(
const
std::string &s) :
Error
(s) {}
21
};
22
23
class
Match
24
{
25
public
:
26
Match
(
const
std::string &s) : s(s) {};
27
~
Match
() {};
28
29
friend
std::istream& operator>>(std::istream &in,
const
Match
&match);
30
31
private
:
32
const
std::string s;
33
};
34
35
inline
std::istream& operator>>(std::istream &in,
const
Match
&match)
36
{
37
std::string t;
38
in >> t;
39
if
(match.s != t)
throw
MatchError
40
(std::string(
"expected `"
) + match.s +
"', found `"
+ t +
"'"
);
41
return
in;
42
}
43
44
}
45
46
#endif
47
nuklei
Public namespace.
Definition:
Color.cpp:9
nuklei::Match
Definition:
Match.h:23
nuklei::Error
Nuklei-related errors.
Definition:
Common.h:205
Common.h
nuklei::MatchError
Definition:
Match.h:17
© Copyright 2007-2013 Renaud Detry.
Distributed under the terms of the GNU General Public License (GPL).
(See accompanying file
LICENSE.txt
or copy at
http://www.gnu.org/copyleft/gpl.html
.)
Revised Sun Sep 13 2020 19:10:06.