E-MailRelay

gfactoryparser.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2021 Graeme Walker <graeme_walker@users.sourceforge.net>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16// ===
17///
18/// \file gfactoryparser.h
19///
20
21#ifndef G_SMTP_FACTORY_PARSER_H
22#define G_SMTP_FACTORY_PARSER_H
23
24#include "gdef.h"
25#include <utility>
26#include <string>
27
28 namespace GSmtp
29{
30 class FactoryParser ;
31}
32
33//| \class GSmtp::FactoryParser
34/// A simple static class to parse identifiers that are either a
35/// program path or a network address. Used by the filter factory
36/// and the address-verifier factory.
37///
38 class GSmtp::FactoryParser
39{
40 public:
41 struct Result /// Result tuple for GSmtp::FactoryParser::parse().
42 {
43 Result() ;
44 Result( const std::string & , const std::string & ) ;
45 Result( const std::string & , const std::string & , int ) ;
46 std::string first ; // eg. "file", "net", "spam"
47 std::string second ; // eg. "localhost:99"
48 int third{0} ; // eg. 1 for spam-edit
49 } ;
50
51 static Result parse( const std::string & identifier , bool allow_spam ) ;
52 ///< Parses an identifier like "/usr/bin/foo" or "net:127.0.0.1:99"
53 ///< or "net:/run/spamd.s", returning the type and the specification
54 ///< in a result tuple, eg. ("file","/usr/bin/foo") or
55 ///< ("net","127.0.0.1:99"). Returns a default-constructed Result
56 ///< if not parsable.
57
58 static std::string check( const std::string & identifier , bool allow_spam ) ;
59 ///< Parses and checks an identifier. Returns a diagnostic if
60 ///< the identifier is invalid, or the empty string if valid
61 ///< or empty.
62
63 public:
64 FactoryParser() = delete ;
65} ;
66
67#endif
GSmtp::FactoryParser
A simple static class to parse identifiers that are either a program path or a network address.
Definition: gfactoryparser.h:39
GSmtp::FactoryParser::parse
static Result parse(const std::string &identifier, bool allow_spam)
Parses an identifier like "/usr/bin/foo" or "net:127.0.0.1:99" or "net:/run/spamd....
Definition: gfactoryparser.cpp:30
GSmtp::FactoryParser::check
static std::string check(const std::string &identifier, bool allow_spam)
Parses and checks an identifier.
Definition: gfactoryparser.cpp:63
GSmtp
SMTP and message-store classes.
Definition: gadminserver.h:39
GSmtp::FactoryParser::Result
Result tuple for GSmtp::FactoryParser::parse().
Definition: gfactoryparser.h:42