From 817510b29ea5de74c6b7cb5d3e2231bdfa06c66a Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Mon, 7 Jul 2014 21:03:18 +0200 Subject: [PATCH] Exported get_parameter_information_string in DLL Signed-off-by: Ian Bell --- include/CoolPropLib.h | 15 ++++----------- src/CoolPropLIB.cpp | 13 +++++++++++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/CoolPropLib.h b/include/CoolPropLib.h index 8c6bf030..52e42316 100644 --- a/include/CoolPropLib.h +++ b/include/CoolPropLib.h @@ -39,7 +39,7 @@ /* #################################################################################### - Overloads for DLL wrapping puposes + Overloads for DLL wrapping purposes These functions take strings which are 0-terminated. These functions pass directly to equivalently named functions in CoolProp.h that take std::string @@ -76,16 +76,9 @@ \sa IsFluidType(std::string, std::string) */ EXPORT_CODE int CONVENTION IsFluidType(const char *Ref, const char *Type); - - // When using SWIG, it is extremely difficult to deal with char* for output strings, so just use - // the std::string version since SWIG can handle std::string just fine - #if defined(SWIG) - std::string get_global_param_string(std::string ParamName); - std::string get_fluid_param_string(std::string FluidName, std::string ParamName); - #else - EXPORT_CODE long CONVENTION get_global_param_string(const char *param, char *Output); - EXPORT_CODE long CONVENTION get_fluid_param_string(const char *fluid, const char *param, char *Output); - #endif + EXPORT_CODE long CONVENTION get_global_param_string(const char *param, char *Output); + EXPORT_CODE long CONVENTION get_parameter_information_string(const char *key, char *Output); + EXPORT_CODE long CONVENTION get_fluid_param_string(const char *fluid, const char *param, char *Output); /** \overload diff --git a/src/CoolPropLIB.cpp b/src/CoolPropLIB.cpp index 675af7ff..3a8e8538 100644 --- a/src/CoolPropLIB.cpp +++ b/src/CoolPropLIB.cpp @@ -156,18 +156,27 @@ EXPORT_CODE void CONVENTION set_debug_level(int level){ EXPORT_CODE long CONVENTION get_param_index(const char * param){ return CoolProp::get_parameter_index(param); } -#ifndef SWIG EXPORT_CODE long CONVENTION get_global_param_string(const char *param, char * Output) { strcpy(Output,CoolProp::get_global_param_string(param).c_str()); return 0; } +EXPORT_CODE long CONVENTION get_parameter_information_string(const char *param, char * Output) +{ + int key = CoolProp::get_parameter_index(param); + if (key >= 0){ + strcpy(Output, CoolProp::get_parameter_information(key, Output).c_str()); + } + else{ + strcpy(Output, format("parameter is invalid: %s", param).c_str()); + } + return 0; +} //EXPORT_CODE long CONVENTION get_fluid_param_string(const char *fluid, const char *param, char * Output) //{ // strcpy(Output, get_fluid_param_string(std::string(fluid), std::string(param)).c_str()); // return 0; //} -#endif EXPORT_CODE double CONVENTION HAPropsSI(const char *Output, const char *Name1, double Prop1, const char *Name2, double Prop2, const char * Name3, double Prop3)