#include <vRegistry.h>
Public Types | |
typedef void(* | fptr )() |
Public Member Functions | |
Registration (std::vector< tString > flags, tString fname, int argc, fptr ctor) | |
Registration (const char *flags, const char *fname, int argc, fptr ctor) | |
Expr::Base * | use (arglist) |
bool | match (std::vector< tString > flags, tString fname, int argc) |
Private Attributes | |
std::vector< tString > | m_flags |
tString | m_fname |
int | m_argc |
fptr | m_ctor |
Definition at line 49 of file vRegistry.h.
typedef void(* vValue::Registry::Registration::fptr)() |
vValue::Registry::Registration::Registration | ( | std::vector< tString > | flags, | |
tString | fname, | |||
int | argc, | |||
fptr | ctor | |||
) |
Definition at line 34 of file vRegistry.cpp.
References vValue::Registry::Registry::reg(), and Registry::theRegistry().
00034 : 00035 m_flags(flags), 00036 m_fname(fname), 00037 m_argc(argc), 00038 m_ctor(ctor) 00039 { 00040 Registry::theRegistry().reg(this); 00041 }
vValue::Registry::Registration::Registration | ( | const char * | flags, | |
const char * | fname, | |||
int | argc, | |||
fptr | ctor | |||
) |
Definition at line 43 of file vRegistry.cpp.
References m_flags, vValue::Registry::Registry::reg(), and Registry::theRegistry().
00043 : 00044 m_fname(fname), 00045 m_argc(argc), 00046 m_ctor(ctor) 00047 { 00048 m_flags.clear(); 00049 for ( 00050 const char *ptr = flags, *ep; 00051 ptr; 00052 ptr = (ep[0] == '\0') ? 0 : (ep + 1) 00053 ) 00054 { 00055 ep = strchr(ptr, '\n'); 00056 if (!ep) 00057 ep = ptr + strlen(ptr); 00058 std::string s(ptr, ep - ptr); 00059 m_flags.push_back(s); 00060 } 00061 Registry::theRegistry().reg(this); 00062 }
Expr::Base * vValue::Registry::Registration::use | ( | arglist | args | ) |
Definition at line 66 of file vRegistry.cpp.
References m_ctor.
00066 { 00067 switch (args.size()) { 00068 case 0: return ((ctor::a0*)m_ctor)(); 00069 case 1: return ((ctor::a1*)m_ctor)(args[0]); 00070 case 2: return ((ctor::a2*)m_ctor)(args[0], args[1]); 00071 case 3: return ((ctor::a3*)m_ctor)(args[0], args[1], args[2]); 00072 case 4: return ((ctor::a4*)m_ctor)(args[0], args[1], args[2], args[3]); 00073 case 5: return ((ctor::a5*)m_ctor)(args[0], args[1], args[2], args[3], args[4]); 00074 } 00075 throw("Unimplemented # of args"); 00076 }
bool vValue::Registry::Registration::match | ( | std::vector< tString > | flags, | |
tString | fname, | |||
int | argc | |||
) |
Definition at line 79 of file vRegistry.cpp.
References tString::Compare(), m_argc, m_fname, and tString::SubStr().
00080 { 00081 if (fname.Compare(m_fname, true)) 00082 return false; 00083 for (std::vector<tString>::iterator i = flags.begin(); i != flags.end(); ++i) 00084 { 00085 bool flagmatch = (flags[0] == "!"); 00086 tString flag = *i; 00087 if (flagmatch) 00088 flag = flag.SubStr(1); 00089 if (!flag.Compare(*i, true)) 00090 flagmatch = !flagmatch; 00091 if (!flagmatch) 00092 return false; 00093 } 00094 if (argc != m_argc) 00095 return false; 00096 return true; 00097 }
std::vector<tString> vValue::Registry::Registration::m_flags [private] |
int vValue::Registry::Registration::m_argc [private] |
fptr vValue::Registry::Registration::m_ctor [private] |