This is the mail archive of the c++-embedded@sourceware.cygnus.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

static function tables


What's the right way to do static tables containing function pointers in
C++?

I have an embedded C app that parses a command from a host and looks it
up in a group of tables. Each table represents an array of related
commands. It contains an 8-byte char[] of the command, a parameter
count, some flags, and a pointer to the function that handles that
command. There are several such tables, linked in based on what feature
set a given app will have.

When I move this app to C++, what's a reasonable OOP-ish way of handling
these tables?

To make command-lookup fast, a table is alphabatized and coded in
assembler (so that I can place labels within the array) and a parallel
26-word array of pointers points to the first command starting with a
given letter. Any suggestions for improvement? A typical table might
have 20-100 commands and an app might have 3-10 tables.

-- 
Ken
mailto:shiva@well.com
mailto:shiva@CompuServe.COM
http://www.well.com/user/shiva/
http://sewnsurf.home.ml.org/
http://www.e-scrub.com/cgi-bin/wpoison/wpoison.cgi (Death to Spam!)






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]