diff --git a/src/SQLParserResult.h b/src/SQLParserResult.h index 96e19cf..0e4e562 100644 --- a/src/SQLParserResult.h +++ b/src/SQLParserResult.h @@ -15,7 +15,7 @@ namespace hsql { // Takes ownership of the statement. SQLParserResult(SQLStatement* stmt); - // Deletes all statements in the resul. + // Deletes all statements in the result. virtual ~SQLParserResult(); // Returns true if parsing was successful. @@ -40,7 +40,7 @@ namespace hsql { SQLStatement* getMutableStatement(int index); // Adds a statement to the result list of statements. - // Takes ownership of the statement. + // SQLParserResult takes ownership of the statement. void addStatement(SQLStatement* stmt); // Set whether parsing was successful. diff --git a/src/sql/Expr.cpp b/src/sql/Expr.cpp index 40209ab..1345714 100644 --- a/src/sql/Expr.cpp +++ b/src/sql/Expr.cpp @@ -155,32 +155,32 @@ namespace hsql { return e; } - bool Expr::isType(ExprType e_type) { - return e_type == type; + bool Expr::isType(ExprType exprType) const { + return exprType == type; } - bool Expr::isLiteral() { + bool Expr::isLiteral() const { return isType(kExprLiteralInt) || isType(kExprLiteralFloat) || isType(kExprLiteralString) || isType(kExprPlaceholder); } - bool Expr::hasAlias() { + bool Expr::hasAlias() const { return alias != NULL; } - bool Expr::hasTable() { + bool Expr::hasTable() const { return table != NULL; } - char* Expr::getName() { + const char* Expr::getName() const { if (alias != NULL) return alias; else return name; } - bool Expr::isSimpleOp() { + bool Expr::isSimpleOp() const { return opType == kOpSimple; } - bool Expr::isSimpleOp(char op) { + bool Expr::isSimpleOp(char op) const { return isSimpleOp() && opChar == op; } diff --git a/src/sql/Expr.h b/src/sql/Expr.h index 810895b..536bd31 100644 --- a/src/sql/Expr.h +++ b/src/sql/Expr.h @@ -36,7 +36,7 @@ namespace hsql { kOpCase, // Binary operators. - // Simple operators are identified by the opChar field (e.g. =, >, <). + // Simple operators are identified by the opChar field (e.g. +, -, =, >, <). kOpSimple, kOpNotEquals, @@ -60,13 +60,9 @@ namespace hsql { // Represents SQL expressions (i.e. literals, operators, column_refs). // TODO: When destructing a placeholder expression, we might need to alter the placeholder_list. struct Expr { - - Expr(ExprType type); - // Interesting side-effect: - // Making the destructor virtual used to cause segmentation faults. - // TODO: inspect. - ~Expr(); + Expr(ExprType type); + virtual ~Expr(); ExprType type; @@ -89,19 +85,19 @@ namespace hsql { // Convenience accessor methods. - bool isType(ExprType e_type); + bool isType(ExprType exprType) const; - bool isLiteral(); + bool isLiteral() const; - bool hasAlias(); + bool hasAlias() const; - bool hasTable(); + bool hasTable() const; - char* getName(); + const char* getName() const; - bool isSimpleOp(); + bool isSimpleOp() const; - bool isSimpleOp(char op); + bool isSimpleOp(char op) const; // Static constructors. diff --git a/src/sql/SelectStatement.h b/src/sql/SelectStatement.h index bb60836..7606e68 100644 --- a/src/sql/SelectStatement.h +++ b/src/sql/SelectStatement.h @@ -13,7 +13,6 @@ namespace hsql { /** * Description of the order by clause within a select statement - * TODO: hold multiple expressions to be sorted by */ struct OrderDescription { OrderDescription(OrderType type, Expr* expr); @@ -41,8 +40,7 @@ namespace hsql { */ struct GroupByDescription { GroupByDescription(); - // TODO: make virtual - ~GroupByDescription(); + virtual ~GroupByDescription(); std::vector* columns; Expr* having; diff --git a/src/sql/Table.h b/src/sql/Table.h index 58ecca4..745d5f1 100644 --- a/src/sql/Table.h +++ b/src/sql/Table.h @@ -35,10 +35,10 @@ namespace hsql { JoinDefinition* join; // Returns true if a schema is set. - bool hasSchema(); + bool hasSchema() const; // Returns the alias, if it is set. Otherwise the name. - char* getName(); + const char* getName() const; }; // Possible types of joins. diff --git a/src/sql/statements.cpp b/src/sql/statements.cpp index 69ffc84..75b794f 100644 --- a/src/sql/statements.cpp +++ b/src/sql/statements.cpp @@ -268,11 +268,11 @@ namespace hsql { } } - bool TableRef::hasSchema() { + bool TableRef::hasSchema() const { return schema != NULL; } - char* TableRef::getName() { + const char* TableRef::getName() const { if (alias != NULL) return alias; else return name; }