NO-JIRA: [C++ binding] Unifying safe conversion from const char* -> std::string
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/25984b80 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/25984b80 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/25984b80 Branch: refs/heads/master Commit: 25984b80f678df142203fb868f612dfefde486d2 Parents: 75faa18 Author: Andrew Stitcher <[email protected]> Authored: Wed Apr 27 17:57:46 2016 -0400 Committer: Andrew Stitcher <[email protected]> Committed: Wed Apr 27 17:58:40 2016 -0400 ---------------------------------------------------------------------- proton-c/bindings/cpp/src/error_condition.cpp | 11 ++++------- proton-c/bindings/cpp/src/proton_bits.hpp | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/25984b80/proton-c/bindings/cpp/src/error_condition.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/error_condition.cpp b/proton-c/bindings/cpp/src/error_condition.cpp index 07abddb..b575596 100644 --- a/proton-c/bindings/cpp/src/error_condition.cpp +++ b/proton-c/bindings/cpp/src/error_condition.cpp @@ -20,17 +20,14 @@ */ #include "proton/error_condition.hpp" #include "proton/condition.h" -namespace { -inline std::string safe_convert(const char* s) { - return s ? s : std::string(); -} -} + +#include "proton_bits.hpp" namespace proton { error_condition::error_condition(pn_condition_t* c) : - name_(safe_convert(pn_condition_get_name(c))), - description_(safe_convert(pn_condition_get_description(c))), + name_(str(pn_condition_get_name(c))), + description_(str(pn_condition_get_description(c))), properties_(pn_condition_info(c)) {} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/25984b80/proton-c/bindings/cpp/src/proton_bits.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/proton_bits.hpp b/proton-c/bindings/cpp/src/proton_bits.hpp index 0c244c5..a3f2039 100644 --- a/proton-c/bindings/cpp/src/proton_bits.hpp +++ b/proton-c/bindings/cpp/src/proton_bits.hpp @@ -47,7 +47,7 @@ std::ostream& operator<<(std::ostream& o, const inspectable& object); void set_error_condition(const error_condition&, pn_condition_t*); /// Convert a const char* to std::string, convert NULL to the empty string. -inline std::string str(const char* s) { return s ? s : ""; } +inline std::string str(const char* s) { return s ? s : std::string(); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
