Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #9487
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | "Gernot Frisch" <me@privacy.net> |
| Newsgroups | comp.lang.c++ |
| Subject | access members by string name |
| Date | Tue, 30 Aug 2011 16:53:35 +0200 |
| Lines | 28 |
| Message-ID | <9c4brfFfu2U1@mid.individual.net> (permalink) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; format=flowed; charset="iso-8859-1"; reply-type=original |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net DZyr6PcJsK4ilsIGfb2Wbg35ymGXLI4vblqcdv0qpOTsfke+I= |
| Cancel-Lock | sha1:bDeFafEmSH3MN6zbthLeOnIJ/LI= |
| X-Priority | 3 |
| X-MSMail-Priority | Normal |
| Importance | Normal |
| X-Newsreader | Microsoft Windows Live Mail 15.4.3538.513 |
| X-MimeOLE | Produced By Microsoft MimeOLE V15.4.3538.513 |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.c++:9487 |
Show key headers only | View raw
Hi,
assume you have a class with members (or member get/set functions) and want
to call them by a string name with the least code to maintain.
I like to just have one macro line per member. The class should have a
working assignment operator.
The end class should look like:
class foo
{
int bar;
int goo;
public:
...
int GetGoo()const {return goo;}
void SetGoo(int g) {goo = g;}
...
std::map<std::string, something_to_map_the_GET_function> getfunctions;
static std::string GetAllParams() {return std::string("bar,goo");}
int GetVar(std::string name) {return getfunctions[name] () ; }
};
Back to comp.lang.c++ | Previous | Next — Next in thread | Find similar | Unroll thread
access members by string name "Gernot Frisch" <me@privacy.net> - 2011-08-30 16:53 +0200
Re: access members by string name Paavo Helde <myfirstname@osa.pri.ee> - 2011-08-30 10:26 -0500
Re: access members by string name "Gernot Frisch" <me@privacy.net> - 2011-08-31 11:58 +0200
Re: access members by string name Michael DOUBEZ <michael.doubez@free.fr> - 2011-08-31 04:08 -0700
csiph-web