HyriseSQLParser/src/lib/statements/SQLStatement.h

80 lines
1.3 KiB
C
Raw Normal View History

2014-10-09 01:30:22 +02:00
/*
2014-12-03 17:43:02 +01:00
* SQLStatement.h
2014-10-09 01:30:22 +02:00
* Definition of the structure used to build the syntax tree.
*/
#ifndef __STATEMENT_H__
#define __STATEMENT_H__
2014-10-20 22:33:36 +02:00
#include "List.h"
2015-01-06 15:29:18 +01:00
#include "Expr.h"
#include <vector>
2014-10-09 01:30:22 +02:00
namespace hsql {
2014-10-09 01:30:22 +02:00
typedef enum {
2014-11-13 01:27:47 +01:00
kStmtError, // Unused
2014-10-27 11:23:31 +01:00
kStmtSelect,
2014-11-07 01:09:06 +01:00
kStmtImport,
2014-11-26 00:26:20 +01:00
kStmtInsert,
2014-11-26 12:19:33 +01:00
kStmtUpdate,
2014-10-27 11:23:31 +01:00
kStmtDelete,
2014-11-07 01:09:06 +01:00
kStmtCreate,
kStmtDrop,
kStmtPrepare,
kStmtExecute,
2014-11-07 01:09:06 +01:00
kStmtExport,
kStmtRename,
kStmtAlter
2014-10-27 11:23:31 +01:00
} StatementType;
2014-10-09 01:30:22 +02:00
2014-12-15 18:32:46 +01:00
/**
* @struct SQLStatement
* @brief Base class for every SQLStatement
*/
2014-12-03 17:43:02 +01:00
struct SQLStatement {
SQLStatement(StatementType type) :
_type(type) {};
2014-11-13 01:27:47 +01:00
2014-12-15 18:32:46 +01:00
virtual ~SQLStatement() {}
2014-12-03 17:43:02 +01:00
virtual StatementType type() { return _type; }
private:
StatementType _type;
};
2014-12-15 18:32:46 +01:00
/**
* @struct SQLStatementList
* @brief Represents the result of the SQLParser. If parsing was successful it is a list of SQLStatement.
*/
2014-12-03 17:43:02 +01:00
class SQLStatementList : public List<SQLStatement*> {
public:
2014-12-03 17:43:02 +01:00
SQLStatementList() :
List<SQLStatement*>(),
2014-11-13 01:27:47 +01:00
isValid(true),
parser_msg(NULL) {};
2014-12-03 17:43:02 +01:00
SQLStatementList(SQLStatement* stmt) :
List<SQLStatement*>(stmt),
2014-11-13 01:27:47 +01:00
isValid(true),
parser_msg(NULL) {};
2014-12-15 18:32:46 +01:00
virtual ~SQLStatementList() {
delete parser_msg;
}
2015-01-06 15:29:18 +01:00
bool isValid;
2014-11-04 00:02:40 +01:00
const char* parser_msg;
2014-12-15 14:43:42 +01:00
int error_line;
int error_col;
2014-10-09 01:30:22 +02:00
};
2014-12-03 17:43:02 +01:00
2014-10-09 01:30:22 +02:00
} // namespace hsql
2014-10-20 22:33:36 +02:00
#endif // __STATEMENT_H__