::DBus::Struct member access

Leonel Florin Selles leonel.florin at cfg.jovenclub.cu
Tue Dec 3 08:43:31 PST 2013


 

Hi friends: 

I'm using dbus-c++-1 to communicate two apps, so, I
invoke a method that returns an ::DBus::Struct like 

::DBus::Struct<
::DBus::Struct< int32_t, std::string, double, int32_t, int32_t, bool >,
int32_t, std::string, std::string, std::string, std::string, double >


until here all is ok, the problem is when I'm trying to access his
members. The normal struct member access is using the (.) or (->)
operator like 

struct Person { 

string name; 

int age; 

}; 

Person
me; 

me.name = "Peter"; 

me.age = 28; 

but in the dbus struct case,
the members do not have any name, so, I use this technique


::DBus::Struct< ::DBus::Struct< int32_t, std::string, double, int32_t,
int32_t, bool >, int32_t, std::string, std::string, std::string,
std::string, double > returnData = 
 { {12, string("TM3"), 5.00, 1, 1,
false}, 13, string("Peter"), string("Florin"), string("Selles"),
string("develop"), 200.00 };

 ::DBus::Struct< int32_t, std::string,
double, int32_t, int32_t, bool > * innerStruct = (::DBus::Struct<
int32_t, std::string, double, int32_t, int32_t, bool > *)&returnData;


/*Service * service = new Service;
 service->id = ((int *)
innerStruct)[0];
 service->Name = ((string *) innerStruct)[1];

service->Rate = ((double *) innerStruct)[2];
 service->CollectUnit =
((int *) innerStruct)[3];
 service->ServiceType = ((int *)
innerStruct)[4];
 service->FreeOfCharge = ((bool *) innerStruct)[5];


but I get some error accessing the data, some one can tell me a
different way to accomplish this, or a wait to declare dbus struct whit
member names.

-- 

 
 ________________________________________________________________
 XII Edicion del Evento Nacional de Informatica para Jovenes. INFOCLUB.
 Septiembre. 2014. Ver www.jovenclub.cu
 ________________________________________________________________

-- 
Este mensaje ha sido analizado por MailScanner
en busca de virus y otros contenidos peligrosos,
y se considera que está limpio.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20131203/6007b7e0/attachment.html>


More information about the dbus mailing list