From 6ded80a9b5e49da2eed0208983f918016c41d818 Mon Sep 17 00:00:00 2001 From: Felipe Magno de Almeida Date: Fri, 15 Sep 2017 14:53:19 -0300 Subject: [PATCH] eo-cxx: Fix conversion from char* to std::string --- src/bindings/cxx/eo_cxx/eo_cxx_interop.hh | 35 +++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh b/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh index 47b11db..0bf92b5 100644 --- a/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh +++ b/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh @@ -749,7 +749,9 @@ inline eina::string_view convert_to_return(const char** value, tag) +template +inline std::string convert_to_return(const char* value, tag + , typename std::enable_if::type, std::string>::value>::type* = 0) { if(value) { @@ -760,7 +762,36 @@ inline std::string convert_to_return(const char* value, tag) +template +inline std::string convert_to_return(const char** value, tag + , typename std::enable_if::type, std::string>::value>::type* = 0) +{ + if(value) + { + std::string r{*value}; + free((void*)*value); + free((void*)value); + return r; + } + else + return {}; +} +template +inline std::string convert_to_return(char* value, tag + , typename std::enable_if::type, std::string>::value>::type* = 0) +{ + if(value) + { + std::string r{value}; + free((void*)value); + return r; + } + else + return {}; +} +template +inline std::string convert_to_return(char** value, tag + , typename std::enable_if::type, std::string>::value>::type* = 0) { if(value) { -- 2.7.4