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;
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* makeOpBinary(Expr* expr1, char op, Expr* expr2);
static Expr* makeOpBinary(Expr* expr1, OperatorType op, Expr* expr2);

View File

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