diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-06-26 21:45:29 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-06-26 21:45:29 +0900 |
| commit | d485c8e76758c68ce55e9554d339eaf715ae7bca (patch) | |
| tree | 51ecc085110b4598159f980105f51eb87eaeceb0 /src/AuthConfig.cc | |
| parent | a4cf50914dc5c5ca1a363b9f63a34eeb3c17cee4 (diff) | |
Rewrite AuthConfig objects using std::unique_ptr
Diffstat (limited to 'src/AuthConfig.cc')
| -rw-r--r-- | src/AuthConfig.cc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/AuthConfig.cc b/src/AuthConfig.cc index ed9c465f..379eb6f8 100644 --- a/src/AuthConfig.cc +++ b/src/AuthConfig.cc @@ -42,9 +42,9 @@ namespace aria2 { AuthConfig::AuthConfig() {} -AuthConfig::AuthConfig(const std::string& user, const std::string& password) - : user_(user), - password_(password) +AuthConfig::AuthConfig(std::string user, std::string password) + : user_(std::move(user)), + password_(std::move(password)) {} AuthConfig::~AuthConfig() {} @@ -57,6 +57,16 @@ std::string AuthConfig::getAuthText() const return s; } +std::unique_ptr<AuthConfig> AuthConfig::create +(std::string user, std::string password) +{ + if(user.empty()) { + return std::unique_ptr<AuthConfig>(); + } else { + return make_unique<AuthConfig>(std::move(user), std::move(password)); + } +} + std::ostream& operator<<(std::ostream& o, const std::shared_ptr<AuthConfig>& authConfig) { |
