Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Get/set value to members of a struct/class on fly

Reply
Thread Tools

Get/set value to members of a struct/class on fly

 
 
Matt
Guest
Posts: n/a
 
      07-25-2003
Hi all,

Suppose I have a bunch of similar structs/classes in a format like this:
struct s1{
int arg1;
char arg2[SIZE];
};

struct s2{
char arg1[SIZE];
int arg2;
float arg3;
};
....
struct sN{
int flag;
s1 arr1;
};


Then I need a general method(of course, we can do it one by one to pull
out/assign values from/to these structs with something like this(we don't
care mem alloc, and we also have a migic buf which can accept/supply
necessary values on demand btw :
void set_values_for_any_struct (struct *assignto, point *migbuf, int
arrdepth, .., any other stuff)
{
/*
suppose we know in advance the assignto is sN *
and we even know sN has two members, and what their types are, but since
this method should fit all structs we can't use assignto->flag =
migbuf.value to assign the value, is there a way to do so?
*/
???
}
// same thing for get

(I'm doing this for a soap client(not server) app, not sure param's name in
soap1.2 is significant means server decides the name and I may not be able
to change them. but I don't have ideas even I can decide the struct and its
members names for soap1.1)
Anyway, help!

-m


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
To Fly or not to fly? Should I move from Mozilla 1.5 to T-bird andF-bird? Daniel Steinberg Firefox 7 11-06-2003 11:31 AM
To Fly or not to fly? Should I move from Mozilla 1.5 to T-bird andF-bird? Daniel Steinberg Firefox 5 11-05-2003 06:23 AM
Get/set value to members of a struct/class on fly Matt C++ 1 07-25-2003 08:25 PM
Get/set value to members of a struct/class on fly Matt C++ 0 07-25-2003 12:49 PM
Get/set value to members of a struct/class on fly Matt C++ 0 07-25-2003 01:57 AM



Advertisments