28GSmtp::VerifierStatus::VerifierStatus()
32 bool temporary ,
const std::string & response ,
const std::string & reason )
35 status.is_valid = false ;
36 status.temporary = temporary ;
37 status.recipient = recipient ;
38 status.response = response ;
39 status.reason = reason ;
44 const std::string & address )
47 status.is_valid = true ;
48 status.is_local = false ;
49 status.recipient = recipient ;
50 status.address = address.empty() ? recipient : address ;
55 const std::string & full_name ,
const std::string & mbox )
58 status.is_valid = true ;
59 status.is_local = true ;
60 status.recipient = recipient ;
61 status.full_name = full_name ;
62 status.address = mbox ;
72 if( part.size() != 9U )
73 throw InvalidStatus() ;
77 s.recipient = part.at(i++) ;
78 s.is_valid = part.at(i++) ==
"1" ;
79 s.is_local = part.at(i++) ==
"1" ;
80 s.temporary = part.at(i++) ==
"1" ;
81 s.abort = part.at(i++) ==
"1" ;
82 s.full_name = part.at(i++) ;
83 s.address = part.at(i++) ;
84 s.response = part.at(i++) ;
85 s.reason = part.at(i++) ;
88 catch( std::exception & )
90 G_ERROR(
"GSmtp::VerifierStatus::parse: invalid verifier status: [" << line <<
"]" ) ;
97 auto escape = [](
const std::string &s){
return G::Str::escaped( s ,
'\\' ,
"\\|" ,
"\\|" ) ; } ;
98 const char sep =
'|' ;
101 return escape(recipient)
103 .append(1U,is_valid?t:f).append(1U,sep)
104 .append(1U,is_local?t:f).append(1U,sep)
105 .append(1U,temporary?t:f).append(1U,sep)
106 .append(1U,abort?t:f).append(1U,sep)
107 .append(escape(full_name)).append(1U,sep)
108 .append(escape(address)).append(1U,sep)
109 .append(escape(response)).append(1U,sep)
110 .append(escape(reason)) ;
A structure returned by GSmtp::Verifier to describe the status of a 'rcpt-to' or 'vrfy' recipient.
static VerifierStatus local(const std::string &recipient, const std::string &full_name, const std::string &mbox)
Constructor for a valid local mailbox.
std::string str() const
Returns a string representation of the structure.
static VerifierStatus parse(const std::string &str)
Parses a str() string into a structure.
static VerifierStatus invalid(const std::string &recipient, bool temporary=false, const std::string &response={}, const std::string &reason={})
Factory for an invalid address.
static VerifierStatus remote(const std::string &recipient, const std::string &address={})
Constructor for a valid remote mailbox.
static void splitIntoFields(const std::string &in, StringArray &out, string_view ws, char escape='\0', bool remove_escapes=true)
Splits the string into fields.
static std::string escaped(const std::string &, char c_escape, const std::string &specials_in, const std::string &specials_out)
Returns the escape()d string.
std::vector< std::string > StringArray
A std::vector of std::strings.