I I suspect you are not treating member as an array so you always get the first elements.
it should be something like this:
member[i].Get("s", &str);
where i
is the next element.
Example code showing setting and getting an array of structs:
//Setting an array of structs
MsgArg inputArg[5];
status = inputArg[0].Set("(s)", "Hello");
if(ER_OK != status ) {
printf("unable to set inputArg[0] status = %s\n", QCC_StatusText(status));
}
status = inputArg[1].Set("(s)", "to");
if(ER_OK != status ) {
printf("unable to set inputArg[1] status = %s\n", QCC_StatusText(status));
}
status = inputArg[2].Set("(s)", "all");
if(ER_OK != status ) {
printf("unable to set inputArg[2] status = %s\n", QCC_StatusText(status));
}
status = inputArg[3].Set("(s)", "my");
if(ER_OK != status ) {
printf("unable to set inputArg[3] status = %s\n", QCC_StatusText(status));
}
status = inputArg[4].Set("(s)", "friends");
if(ER_OK != status ) {
printf("unable to set inputArg[4] status = %s\n", QCC_StatusText(status));
}
MsgArg outArg;
status = outArg.Set("a(s)", 5, inputArg);
if(ER_OK != status ) {
printf("unable to set outArg status = %s\n", QCC_StatusText(status));
}
//Getting an array of structs
MsgArg* myOutArg;
size_t myOutArgNum;
status = outArg.Get("a(s)", &myOutArgNum, &myOutArg);
if(ER_OK != status ) {
printf("unable to get myOutArg status = %s\n", QCC_StatusText(status));
}
if(5 != myOutArgNum) {
printf("size of myOutArgNum should be 5 actual size %ul\n", myOutArgNum);
}
const char* outStr[5];
for (size_t i = 0; i < myOutArgNum && i < 5; ++i) {
status = myOutArg[i].Get("(s)", &outStr[i]);
if(ER_OK != status ) {
printf("unable to get struct from myOutArg status = %s\n", QCC_StatusText(status));
}
}
for (size_t i = 0; i < 5; ++i) {
printf("%s ", outStr[i]);
}
printf("\n");
Example using an array of strings this is very similar to the array of structs:
//Setting an array of strings
const char* inputStrs[] = {"Hello", "to", "all", "my", "friends"};
MsgArg outArg;
status = outArg.Set("as", 5, inputStrs);
if(ER_OK != status ) {
printf("unable to set outArg status = %s\n", QCC_StatusText(status));
}
//Getting an array of structs
MsgArg* myOutArg;
size_t myOutArgNum;
status = outArg.Get("as", &myOutArgNum, &myOutArg);
if(ER_OK != status ) {
printf("unable to get myOutArg status = %s\n", QCC_StatusText(status));
}
if(5 != myOutArgNum) {
printf("size of myOutArgNum should be 5 actual size %ul\n", myOutArgNum);
}
const char* outStr[5];
for (size_t i = 0; i < myOutArgNum && i < 5; ++i) {
status = myOutArg[i].Get("s", &outStr[i]);
if(ER_OK != status ) {
printf("unable to get struct from myOutArg status = %s\n", QCC_StatusText(status));
}
}
for (size_t i = 0; i < 5; ++i) {
printf("%s ", outStr[i]);
}
printf("\n");