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.
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.

View File

@ -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;
}

View File

@ -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.

View File

@ -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<Expr*>* columns;
Expr* having;

View File

@ -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.

View File

@ -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;
}