E-MailRelay
gfactoryparser.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2018 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 "gsmtp.h"
26 #include <utility>
27 #include <string>
28 
29 namespace GSmtp
30 {
31  class FactoryParser ;
32 }
33 
34 /// \class GSmtp::FactoryParser
35 /// A simple class to parse identifiers that can be a program
36 /// in the file system or a network address.
37 ///
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 ;
47  std::string second ;
48  int third ;
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  ///< returning the type and the specification in a result tuple, eg.
54  ///< ("file","/usr/bin/foo") or ("net","127.0.0.1:99").
55 
56  static std::string check( const std::string & identifier , bool allow_spam ) ;
57  ///< Parses and checks an identifier. Returns a diagnostic if
58  ///< the identifier is invalid, or the empty string if valid
59  ///< or empty.
60 
61 private:
62  FactoryParser() ; // not implemented
63 } ;
64 
65 #endif
SMTP and message-store classes.
Definition: gadminserver.h:39
Result tuple for GSmtp::FactoryParser::parse().
static std::string check(const std::string &identifier, bool allow_spam)
Parses and checks an identifier.
A simple class to parse identifiers that can be a program in the file system or a network address...
static Result parse(const std::string &identifier, bool allow_spam)
Parses an identifier like "/usr/bin/foo" or "net:127.0.0.1:99" returning the type and the specificati...