From ec1f31e442d43a1e500a3ba7d23ab881bd8874be Mon Sep 17 00:00:00 2001 From: Mika Laitio Date: Wed, 9 Mar 2011 01:44:22 +0200 Subject: [PATCH] Fixed the transfer of double and float parameters in busmessage. Signed-off-by: Mika Laitio --- src/plpbus/BusMessage.cc | 22 +++++++++++----------- src/plpbus/BusMessage.hh | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/plpbus/BusMessage.cc b/src/plpbus/BusMessage.cc index 16eaec4..ea81741 100644 --- a/src/plpbus/BusMessage.cc +++ b/src/plpbus/BusMessage.cc @@ -65,7 +65,7 @@ int BusMessage::add_string_parameter(string arg_name_param, string value_param) return ret_val; } -int BusMessage::add_long_parameter(const char *arg_name_param, long value_param) +int BusMessage::add_long_parameter(string arg_name_param, long value_param) { long length; int ret_val; @@ -74,10 +74,10 @@ int BusMessage::add_long_parameter(const char *arg_name_param, long value_param) ret_val = 0; seq = (DataItemSequence *)_dataItemSeq; - if (arg_name_param != NULL) { + if (arg_name_param.empty() == false) { length = seq->length(); item = new DataItem(); - item->name = strdup(arg_name_param); + item->name = strdup(arg_name_param.c_str()); item->value <<= value_param; seq->length(length + 1); @@ -113,7 +113,7 @@ int BusMessage::add_int_parameter(string arg_name_param, int value_param) return ret_val; } -int BusMessage::add_double_parameter(const char *arg_name_param, double value_param) +int BusMessage::add_double_parameter(string arg_name_param, double value_param) { long length; int ret_val; @@ -123,11 +123,11 @@ int BusMessage::add_double_parameter(const char *arg_name_param, double value_pa ret_val = 0; log_debug("add_double_parameter() started\n"); seq = (DataItemSequence *)_dataItemSeq; - if (arg_name_param != NULL) { + if (arg_name_param.empty() == false) { length = seq->length(); item = new DataItem(); - item->name = strdup(arg_name_param); - item->value <<= (long)value_param; + item->name = strdup(arg_name_param.c_str()); + item->value <<= (double)value_param; seq->length(length + 1); (*seq)[length] = *item; @@ -139,7 +139,7 @@ int BusMessage::add_double_parameter(const char *arg_name_param, double value_pa return ret_val; } -int BusMessage::add_float_parameter(const char *arg_name_param, float value_param) +int BusMessage::add_float_parameter(string arg_name_param, float value_param) { long length; int ret_val; @@ -148,11 +148,11 @@ int BusMessage::add_float_parameter(const char *arg_name_param, float value_para ret_val = 0; seq = (DataItemSequence *)_dataItemSeq; - if (arg_name_param != NULL) { + if (arg_name_param.empty() == false) { length = seq->length(); item = new DataItem(); - item->name = strdup(arg_name_param); - item->value <<= (long)value_param; + item->name = strdup(arg_name_param.c_str()); + item->value <<= (float)value_param; seq->length(length + 1); (*seq)[length] = *item; diff --git a/src/plpbus/BusMessage.hh b/src/plpbus/BusMessage.hh index 4627eb4..2ebd635 100644 --- a/src/plpbus/BusMessage.hh +++ b/src/plpbus/BusMessage.hh @@ -20,10 +20,10 @@ namespace plpbus { BusMessage(long type_param, const char *arg_name_param, const char *arg_string_value_param); virtual ~BusMessage(); int add_string_parameter(std::string arg_name_param, std::string string_value_param); - int add_long_parameter(const char *arg_name_param, long value_param); + int add_long_parameter(std::string arg_name_param, long value_param); int add_int_parameter(std::string arg_name_param, int value_param); - int add_double_parameter(const char *arg_name_param, double value_param); - int add_float_parameter(const char *arg_name_param, float value_param); + int add_double_parameter(std::string arg_name_param, double value_param); + int add_float_parameter(std::string arg_name_param, float value_param); long get_type(int *err_flg); std::string get_string_parameter(std::string arg_name_param, int *err_flg); long get_long_parameter(std::string arg_name_param, int *err_flg); -- 2.41.1