]> pilppa.com Git - libplpbus.git/commitdiff
Fixed the transfer of double and float parameters in busmessage.
authorMika Laitio <lamikr@pilppa.org>
Tue, 8 Mar 2011 23:44:22 +0000 (01:44 +0200)
committerMika Laitio <lamikr@pilppa.org>
Tue, 8 Mar 2011 23:44:22 +0000 (01:44 +0200)
Signed-off-by: Mika Laitio <lamikr@pilppa.org>
src/plpbus/BusMessage.cc
src/plpbus/BusMessage.hh

index 16eaec47fd48faec3b964296d0183e0533e02541..ea81741f335295f783bb2481203cadea1d2d431e 100644 (file)
@@ -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;
index 4627eb46d4b03b17968b907e5f32c1c114619a2b..2ebd63581dd296a5e6b78edc5c43db591795298d 100644 (file)
@@ -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);