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

Discussion in 'C++' started by Matt, Jul 25, 2003.

  1. Matt

    Matt Guest

    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
    Matt, Jul 25, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    0
    Views:
    336
  2. Matt
    Replies:
    1
    Views:
    445
    Buster Copley
    Jul 25, 2003
  3. Matt
    Replies:
    0
    Views:
    377
  4. CoolPint
    Replies:
    8
    Views:
    955
    Jeff Schwab
    Dec 14, 2003
  5. John Reye
    Replies:
    28
    Views:
    1,336
    Tim Rentsch
    May 8, 2012
Loading...

Share This Page