EXPORT_CODE void CONVENTION AbstractState_set_fractions(const long handle, const double *fractions, const long N, long *errcode, char *message_buffer, const long buffer_length) { *errcode = 0; std::vector<double> _fractions(fractions, fractions + N); try{ shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle); if (AS->using_mole_fractions()){ AS->set_mole_fractions(_fractions); } else if (AS->using_mass_fractions()){ AS->set_mass_fractions(_fractions); } else if (AS->using_volu_fractions()){ AS->set_volu_fractions(_fractions); } } catch (...) { HandleException(errcode, message_buffer, buffer_length); } }
EXPORT_CODE void CONVENTION AbstractState_set_fractions(const long handle, const double *fractions, const long N, long *errcode, char *message_buffer, const long buffer_length) { *errcode = 0; std::vector<double> _fractions(fractions, fractions + N); try{ shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle); if (AS->using_mole_fractions()){ AS->set_mole_fractions(_fractions); } else if (AS->using_mass_fractions()){ AS->set_mass_fractions(_fractions); } else if (AS->using_volu_fractions()){ AS->set_volu_fractions(_fractions); } } catch(CoolProp::HandleError &e){ std::string errmsg = std::string("HandleError: ") + e.what(); if (errmsg.size() < static_cast<std::size_t>(buffer_length)){ *errcode = 1; strcpy(message_buffer, errmsg.c_str()); } else{ *errcode = 2; } } catch(CoolProp::CoolPropBaseError &e){ std::string errmsg = std::string("Error: ") + e.what(); if (errmsg.size() < static_cast<std::size_t>(buffer_length)){ *errcode = 1; strcpy(message_buffer, errmsg.c_str()); } else{ *errcode = 2; } } catch(...){ *errcode = 3; } }