Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

NArgs.h

Go to the documentation of this file.
00001 #ifndef NARGS_H 00002 #define NARGS_H 00003 00004 #include "Expression.h" 00005 00006 //BOREALIS_NAMESPACE_BEGIN 00007 using namespace Borealis; 00008 00010 class NArgs 00011 { 00012 public: 00014 static const int VARARGS = -1; 00015 00016 00019 NArgs( ptr<Expression> a = ptr<Expression>(), 00020 ptr<Expression> b = ptr<Expression>(), 00021 ptr<Expression> c = ptr<Expression>() ); 00022 00023 00026 NArgs( const vector<ptr<Expression> >& args ); 00027 00028 00031 void requireNumArgs(int args_required) const throw (ExprException); 00032 00033 00037 void requireNumArgs(int minargs, int maxargs) const throw (ExprException); 00038 00039 00042 void requireArgType( unsigned int index, 00043 DataType type1, 00044 DataType type2 = DataType(), 00045 DataType type3 = DataType(), 00046 DataType type4 = DataType() 00047 ) const 00048 throw( ExprException ); 00049 00050 00053 const ptr<Expression>& arg( unsigned int idx ) const; 00054 00055 00057 unsigned int numArgs() const; 00058 00059 00062 const ptr<Expression>& operator[] (unsigned int idx) const; 00063 00064 00066 unsigned int size() const; 00067 00068 00070 bool empty() const; 00071 00072 00073 protected: 00074 vector<ptr<Expression> > _args; 00075 }; 00076 00077 00078 00093 class Function 00094 { 00095 public: 00104 virtual ptr<Expression> makeExpression( const NArgs &args ) 00105 throw( ExprException ) = 0; 00106 }; 00107 00108 typedef Registry<Function> FunctionRegistry; 00109 #define AURORA_DECLARE_FUNCTION(ClassName) AURORA_DECLARE_REG_CLASS(Function, ClassName) 00110 #define AURORA_DEFINE_FUNCTION(ClassName, FuncName) \ 00111 AURORA_DEFINE_REG_CLASS_WITH_KEY(Function, ClassName, FuncName) 00112 00113 00114 //BOREALIS_NAMESPACE_END 00115 #endif // NARGS_H

Generated on Fri Nov 12 15:15:21 2004 for Borealis by doxygen 1.3.8