🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c++.leda
Article #121

Re: Mapping of Name Tag to a Method Name in C++

#121
From: z.f roadhouse
Date: Sat, 07 Oct 1995 02:35
46 lines
1679 bytes
In article <44up9m$1au@aadt.sdt.com> rmakam@aadt.com (Ravikumar Makam) writes:
> I am trying to map a Name Tag (probably a string/number) to a function/method
> in C++.
>  
> One way of doing it is using IF-ladder
>  
>   if (Name_Tag == this)
>      call thisObject.this_method ()
>  
>   else if (Name_Tag == that)
>      call thatObject.that_method ()
>   :
>   :
>   etc.,

Righto.  I'm doing the same thing for a application scriptor
that I'm writing.  Currently I'm using a LEDA dictionary to associate
a string (read in from a file) and a function call.  The way I'm
currently doing it is:

class Command {
...
  int functioncall(...);
}

class CommandTable {
...
diction<string,Command> myDictionary;
...
void addCommand(string&,Command&);

Command& get(string&);
}

Anyway, I hope you get the general idea.  BTW, if anyone has created
this simple scripting system before...pls mail me.
-- 

|---------------------------------------------|
Zachary F. Roadhouse
Box 220, Brown University, Providence, RI 02912
(401) 863 - 5359
E-MAIL: Zachary_Roadhouse@brown.edu
WWW: http://www.netspace.org/~zack 
|---------------------------------------------|
Technical Details
Message-ID: <ROADHOZF.95Oct6223541@sunserver.engin.brown.edu>
Path: arc1-ca.pugleaf.net!cocoa.brown.edu!news
References: <44up9m$1au@aadt.sdt.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!cocoa.brown.edu!news
From: roadhozf@sunserver.engin.brown.edu (z.f roadhouse)
Newsgroups: comp.lang.c++.leda
Subject: Re: Mapping of Name Tag to a Method Name in C++
Date: 07 Oct 1995 02:35:41 GMT
Organization: Brown University
Distribution: world
Message-ID: <ROADHOZF.95Oct6223541@sunserver.engin.brown.edu>
References: <44up9m$1au@aadt.sdt.com>
NNTP-Posting-Host: sunserver.engin.brown.edu
In-reply-to: rmakam@aadt.com's message of 4 Oct 1995 20:03:02 GMT