From 1978c49bea5b439d993067c055cec47e70db8fd6 Mon Sep 17 00:00:00 2001 From: "Jannis M. Hoffmann" Date: Sat, 7 Oct 2023 22:33:50 +0200 Subject: minor refactoring --- src/address.cc | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/address.cc') diff --git a/src/address.cc b/src/address.cc index eff4ccd..33d216e 100644 --- a/src/address.cc +++ b/src/address.cc @@ -1,35 +1,38 @@ -/** ------------------------------------------------------------------- +/** * @file address.cc * @brief Implementation of the Address class * @author Andreas Aardal Hanssen * @date 2005 - * ---------------------------------------------------------------- **/ + */ + #include "address.h" #include "convert.h" #include -using namespace ::std; using namespace Binc; +using std::string; -//------------------------------------------------------------------------ Address::Address(const string &name, const string &addr) { - string::size_type pos = addr.find('@'); + auto pos = addr.find('@'); + this->name = name; + if (pos != string::npos) { this->local = addr.substr(0, pos); this->host = addr.substr(pos + 1); - } else + } else { this->local = addr; + } } -//------------------------------------------------------------------------ Address::Address(const string &wholeaddress) { - string::size_type start = wholeaddress.find('<'); + auto start = wholeaddress.find('<'); string addr; + if (start != string::npos) addr = wholeaddress.substr(start + 1); else @@ -41,6 +44,7 @@ Address::Address(const string &wholeaddress) name = wholeaddress.substr(0, start); else name = ""; + trim(name); trim(name, "\""); @@ -53,7 +57,6 @@ Address::Address(const string &wholeaddress) trim(name); } -//------------------------------------------------------------------------ string Address::toParenList(void) const { string tmp = "("; -- cgit v1.2.3