-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: replace some ostream use with fmt (#1131)
- Loading branch information
1 parent
efd13ab
commit 58fa97b
Showing
12 changed files
with
187 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,31 @@ | ||
#include "CurlVersion.hpp" | ||
|
||
#include <ostream> | ||
#include <fmt/format.h> | ||
#include <string> | ||
|
||
namespace curl { | ||
|
||
std::ostream& | ||
operator<<(std::ostream& os, const Version& version) { | ||
if (version.data) { | ||
os << version.data->version << " (ssl: "; | ||
if (version.data->ssl_version) { | ||
os << version.data->ssl_version; | ||
std::string | ||
Version::toString() const { | ||
std::string str; | ||
if (data) { | ||
str += data->version; | ||
str += " (ssl: "; | ||
if (data->ssl_version) { | ||
str += data->ssl_version; | ||
} else { | ||
os << "none"; | ||
str += "none"; | ||
} | ||
os << ")"; | ||
str += ")"; | ||
} | ||
return os; | ||
return str; | ||
} | ||
|
||
}; // namespace curl | ||
|
||
auto | ||
fmt::formatter<curl::Version>::format( | ||
const curl::Version& v, format_context& ctx | ||
) const -> format_context::iterator { | ||
return formatter<std::string>::format(v.toString(), ctx); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
#pragma once | ||
|
||
#include <curl/curl.h> | ||
#include <ostream> | ||
#include <fmt/format.h> | ||
#include <string> | ||
|
||
namespace curl { | ||
|
||
struct Version { | ||
curl_version_info_data* data; | ||
|
||
Version() : data(curl_version_info(CURLVERSION_NOW)) {} | ||
}; | ||
|
||
std::ostream& operator<<(std::ostream& os, const Version& version); | ||
std::string toString() const; | ||
}; | ||
|
||
}; // namespace curl | ||
|
||
template <> | ||
struct fmt::formatter<curl::Version> : formatter<std::string> { | ||
auto format(const curl::Version& v, format_context& ctx) const | ||
-> format_context::iterator; | ||
}; |
Oops, something went wrong.