switched to structs insetead of classes

This commit is contained in:
Pedro 2014-10-22 17:42:05 +02:00
parent 1357458094
commit 8e968ffb41
4 changed files with 47 additions and 30 deletions

View File

@ -1,13 +1,15 @@
/*
* Statement.c
* Statement.cpp
* Implementation of functions used to build the syntax tree.
*/
#include "Statement.h"
#include <stdlib.h>
Statement::Statement(EStatementType type) : type(type) {};
Statement::Statement(EStatementType type) : type(type) {
SelectStatement::SelectStatement() : Statement(eSelect) {};
};
TableRef::TableRef(ETableRefType type) : type(type) {};
SelectStatement::SelectStatement() : Statement(eSelect) {
};

View File

@ -7,8 +7,7 @@
#include "Expr.h"
#include "List.h"
class TableRef;
#include "Table.h"
typedef enum {
eSelect,
@ -18,17 +17,14 @@ typedef enum {
} EStatementType;
class Statement {
public:
struct Statement {
Statement(EStatementType type);
EStatementType type;
};
class SelectStatement : public Statement {
public:
struct SelectStatement : Statement {
SelectStatement();
TableRef* from_table;
@ -38,24 +34,17 @@ public:
};
/**
* TableRef
* Holds reference to tables. Can be either table names or a select statement.
*/
typedef enum {
eTableName,
eTableSelect
} ETableRefType;
class TableRef {
public:
TableRef(ETableRefType type);
ETableRefType type;
SelectStatement* stmt;
List<char*>* table_names;
struct DeleteStatement : Statement {
// TODO
};
struct InsertStatement : Statement {
// TODO
};
struct CreateStatement : Statement {
// TODO
};
#endif // __STATEMENT_H__

26
src/lib/Table.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef __TABLEREF_H_
#define __TABLEREF_H_
class SelectStatement;
/**
* TableRef
* Holds reference to tables. Can be either table names or a select statement.
*/
typedef enum {
eTableName,
eTableSelect
} ETableRefType;
struct TableRef {
TableRef(ETableRefType type) : type(type) {}
ETableRefType type;
SelectStatement* stmt;
List<char*>* table_names;
};
#endif

View File

@ -151,7 +151,7 @@ int main(int argc, char *argv[]) {
SelectTest2();
SelectTest3(true);
ThreadSafeTest(10, 1000);
Benchmark1(500000);
Benchmark1(10000);
printf("\n## Finished running all tests...\n");
printf("######################################\n");