added some convenience methods

This commit is contained in:
Pedro 2014-11-17 02:01:24 +01:00
parent 48dbab8258
commit 1c1902538e
2 changed files with 30 additions and 1 deletions

View File

@ -75,6 +75,22 @@ struct Expr {
OperatorType op_type; OperatorType op_type;
char op_char; char op_char;
/**
* Convenience accessor methods
*/
inline bool hasAlias() { return alias != NULL; }
inline char* getName() {
if (alias != NULL) return alias;
else return name;
}
inline bool isSimpleOp() { return op_type == SIMPLE_OP; }
inline bool isSimpleOp(char op) { return isSimpleOp() && op_char == op; }
/**
* Static expression constructors
*/
static Expr* makeOpUnary(OperatorType op, Expr* expr); static Expr* makeOpUnary(OperatorType op, Expr* expr);
static Expr* makeOpBinary(Expr* expr1, char op, Expr* expr2); static Expr* makeOpBinary(Expr* expr1, char op, Expr* expr2);
static Expr* makeOpBinary(Expr* expr1, OperatorType op, Expr* expr2); static Expr* makeOpBinary(Expr* expr1, OperatorType op, Expr* expr2);

View File

@ -31,6 +31,7 @@ typedef struct TableRef TableRef;
struct TableRef { struct TableRef {
TableRef(TableRefType type) : TableRef(TableRefType type) :
type(type), type(type),
schema(NULL),
name(NULL), name(NULL),
alias(NULL), alias(NULL),
select(NULL), select(NULL),
@ -43,17 +44,29 @@ struct TableRef {
TableRefType type; TableRefType type;
char* schema;
char* name; char* name;
char* alias; char* alias;
SelectStatement* select; SelectStatement* select;
List<TableRef*>* list; List<TableRef*>* list;
// Join memberbs // Join members
TableRef* left; TableRef* left;
TableRef* right; TableRef* right;
JoinType join_type; JoinType join_type;
Expr* join_condition; Expr* join_condition;
/**
* Convenience accessor methods
*/
inline bool hasSchema() { return schema != NULL; }
inline char* getName() {
if (alias != NULL) return alias;
else return name;
}
}; };