fix various const constraints and comments

This commit is contained in:
Pedro Flemming 2017-04-06 17:42:46 +02:00
parent eddd799c26
commit 7bce903eb8
6 changed files with 25 additions and 31 deletions

View File

@ -15,7 +15,7 @@ namespace hsql {
// Takes ownership of the statement. // Takes ownership of the statement.
SQLParserResult(SQLStatement* stmt); SQLParserResult(SQLStatement* stmt);
// Deletes all statements in the resul. // Deletes all statements in the result.
virtual ~SQLParserResult(); virtual ~SQLParserResult();
// Returns true if parsing was successful. // Returns true if parsing was successful.
@ -40,7 +40,7 @@ namespace hsql {
SQLStatement* getMutableStatement(int index); SQLStatement* getMutableStatement(int index);
// Adds a statement to the result list of statements. // Adds a statement to the result list of statements.
// Takes ownership of the statement. // SQLParserResult takes ownership of the statement.
void addStatement(SQLStatement* stmt); void addStatement(SQLStatement* stmt);
// Set whether parsing was successful. // Set whether parsing was successful.

View File

@ -155,32 +155,32 @@ namespace hsql {
return e; return e;
} }
bool Expr::isType(ExprType e_type) { bool Expr::isType(ExprType exprType) const {
return e_type == type; return exprType == type;
} }
bool Expr::isLiteral() { bool Expr::isLiteral() const {
return isType(kExprLiteralInt) || isType(kExprLiteralFloat) || isType(kExprLiteralString) || isType(kExprPlaceholder); return isType(kExprLiteralInt) || isType(kExprLiteralFloat) || isType(kExprLiteralString) || isType(kExprPlaceholder);
} }
bool Expr::hasAlias() { bool Expr::hasAlias() const {
return alias != NULL; return alias != NULL;
} }
bool Expr::hasTable() { bool Expr::hasTable() const {
return table != NULL; return table != NULL;
} }
char* Expr::getName() { const char* Expr::getName() const {
if (alias != NULL) return alias; if (alias != NULL) return alias;
else return name; else return name;
} }
bool Expr::isSimpleOp() { bool Expr::isSimpleOp() const {
return opType == kOpSimple; return opType == kOpSimple;
} }
bool Expr::isSimpleOp(char op) { bool Expr::isSimpleOp(char op) const {
return isSimpleOp() && opChar == op; return isSimpleOp() && opChar == op;
} }

View File

@ -36,7 +36,7 @@ namespace hsql {
kOpCase, kOpCase,
// Binary operators. // Binary operators.
// Simple operators are identified by the opChar field (e.g. =, >, <). // Simple operators are identified by the opChar field (e.g. +, -, =, >, <).
kOpSimple, kOpSimple,
kOpNotEquals, kOpNotEquals,
@ -60,13 +60,9 @@ namespace hsql {
// Represents SQL expressions (i.e. literals, operators, column_refs). // Represents SQL expressions (i.e. literals, operators, column_refs).
// TODO: When destructing a placeholder expression, we might need to alter the placeholder_list. // TODO: When destructing a placeholder expression, we might need to alter the placeholder_list.
struct Expr { struct Expr {
Expr(ExprType type);
// Interesting side-effect: Expr(ExprType type);
// Making the destructor virtual used to cause segmentation faults. virtual ~Expr();
// TODO: inspect.
~Expr();
ExprType type; ExprType type;
@ -89,19 +85,19 @@ namespace hsql {
// Convenience accessor methods. // 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. // Static constructors.

View File

@ -13,7 +13,6 @@ namespace hsql {
/** /**
* Description of the order by clause within a select statement * Description of the order by clause within a select statement
* TODO: hold multiple expressions to be sorted by
*/ */
struct OrderDescription { struct OrderDescription {
OrderDescription(OrderType type, Expr* expr); OrderDescription(OrderType type, Expr* expr);
@ -41,8 +40,7 @@ namespace hsql {
*/ */
struct GroupByDescription { struct GroupByDescription {
GroupByDescription(); GroupByDescription();
// TODO: make virtual virtual ~GroupByDescription();
~GroupByDescription();
std::vector<Expr*>* columns; std::vector<Expr*>* columns;
Expr* having; Expr* having;

View File

@ -35,10 +35,10 @@ namespace hsql {
JoinDefinition* join; JoinDefinition* join;
// Returns true if a schema is set. // Returns true if a schema is set.
bool hasSchema(); bool hasSchema() const;
// Returns the alias, if it is set. Otherwise the name. // Returns the alias, if it is set. Otherwise the name.
char* getName(); const char* getName() const;
}; };
// Possible types of joins. // Possible types of joins.

View File

@ -268,11 +268,11 @@ namespace hsql {
} }
} }
bool TableRef::hasSchema() { bool TableRef::hasSchema() const {
return schema != NULL; return schema != NULL;
} }
char* TableRef::getName() { const char* TableRef::getName() const {
if (alias != NULL) return alias; if (alias != NULL) return alias;
else return name; else return name;
} }