From e6cd70f02901471b762cd6dbce02074e84d88476 Mon Sep 17 00:00:00 2001 From: Pedro Flemming Date: Fri, 7 Apr 2017 15:47:51 +0200 Subject: [PATCH] move sqlhelper into util/. Add convenience methods --- example/example.cpp | 2 +- src/sql/SQLStatement.h | 4 +++- src/sql/statements.cpp | 4 ++++ src/{ => util}/sqlhelper.cpp | 0 src/{ => util}/sqlhelper.h | 6 +++--- test/sql_tests.cpp | 6 ++++-- test/tpc_h_tests.cpp | 6 ++++-- 7 files changed, 19 insertions(+), 9 deletions(-) rename src/{ => util}/sqlhelper.cpp (100%) rename src/{ => util}/sqlhelper.h (90%) diff --git a/example/example.cpp b/example/example.cpp index 62a5077..91e5d17 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -6,7 +6,7 @@ #include "SQLParser.h" // contains printing utilities -#include "sqlhelper.h" +#include "util/sqlhelper.h" int main(int argc, char *argv[]) { if (argc <= 1) { diff --git a/src/sql/SQLStatement.h b/src/sql/SQLStatement.h index 1e1e643..9d491d4 100644 --- a/src/sql/SQLStatement.h +++ b/src/sql/SQLStatement.h @@ -29,7 +29,9 @@ namespace hsql { virtual ~SQLStatement(); - virtual StatementType type() const; + StatementType type() const; + + bool isType(StatementType type) const; private: StatementType type_; diff --git a/src/sql/statements.cpp b/src/sql/statements.cpp index 75b794f..bcdece3 100644 --- a/src/sql/statements.cpp +++ b/src/sql/statements.cpp @@ -13,6 +13,10 @@ namespace hsql { return type_; } + bool SQLStatement::isType(StatementType type) const { + return (type_ == type); + } + // ColumnDefinition ColumnDefinition::ColumnDefinition(char* name, DataType type) : name(name), diff --git a/src/sqlhelper.cpp b/src/util/sqlhelper.cpp similarity index 100% rename from src/sqlhelper.cpp rename to src/util/sqlhelper.cpp diff --git a/src/sqlhelper.h b/src/util/sqlhelper.h similarity index 90% rename from src/sqlhelper.h rename to src/util/sqlhelper.h index ea6edd1..7c7e811 100644 --- a/src/sqlhelper.h +++ b/src/util/sqlhelper.h @@ -1,7 +1,7 @@ -#ifndef __SQLHELPER_H__ -#define __SQLHELPER_H__ +#ifndef __SQLPARSER__SQLHELPER_H__ +#define __SQLPARSER__SQLHELPER_H__ -#include "sql/statements.h" +#include "../sql/statements.h" namespace hsql { diff --git a/test/sql_tests.cpp b/test/sql_tests.cpp index 89ccf60..7f7f59a 100644 --- a/test/sql_tests.cpp +++ b/test/sql_tests.cpp @@ -3,9 +3,11 @@ */ #include "thirdparty/microtest/microtest.h" -#include "sql_asserts.h" + #include "SQLParser.h" -#include "sqlhelper.h" +#include "util/sqlhelper.h" + +#include "sql_asserts.h" using namespace hsql; diff --git a/test/tpc_h_tests.cpp b/test/tpc_h_tests.cpp index 6b3387a..288802a 100644 --- a/test/tpc_h_tests.cpp +++ b/test/tpc_h_tests.cpp @@ -1,7 +1,9 @@ #include "thirdparty/microtest/microtest.h" -#include "sql_asserts.h" + #include "SQLParser.h" -#include "sqlhelper.h" +#include "util/sqlhelper.h" + +#include "sql_asserts.h" #include #include