Skip to content

Commit 7bce903

Browse files
committed
fix various const constraints and comments
1 parent eddd799 commit 7bce903

6 files changed

Lines changed: 25 additions & 31 deletions

File tree

‎src/SQLParserResult.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace hsql {
1515
// Takes ownership of the statement.
1616
SQLParserResult(SQLStatement* stmt);
1717

18-
// Deletes all statements in the resul.
18+
// Deletes all statements in the result.
1919
virtual ~SQLParserResult();
2020

2121
// Returns true if parsing was successful.
@@ -40,7 +40,7 @@ namespace hsql {
4040
SQLStatement* getMutableStatement(int index);
4141

4242
// Adds a statement to the result list of statements.
43-
// Takes ownership of the statement.
43+
// SQLParserResult takes ownership of the statement.
4444
void addStatement(SQLStatement* stmt);
4545

4646
// Set whether parsing was successful.

‎src/sql/Expr.cpp‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,32 +155,32 @@ namespace hsql {
155155
return e;
156156
}
157157

158-
bool Expr::isType(ExprType e_type) {
159-
return e_type == type;
158+
bool Expr::isType(ExprType exprType) const {
159+
return exprType == type;
160160
}
161161

162-
bool Expr::isLiteral() {
162+
bool Expr::isLiteral() const {
163163
return isType(kExprLiteralInt) || isType(kExprLiteralFloat) || isType(kExprLiteralString) || isType(kExprPlaceholder);
164164
}
165165

166-
bool Expr::hasAlias() {
166+
bool Expr::hasAlias() const {
167167
return alias != NULL;
168168
}
169169

170-
bool Expr::hasTable() {
170+
bool Expr::hasTable() const {
171171
return table != NULL;
172172
}
173173

174-
char* Expr::getName() {
174+
const char* Expr::getName() const {
175175
if (alias != NULL) return alias;
176176
else return name;
177177
}
178178

179-
bool Expr::isSimpleOp() {
179+
bool Expr::isSimpleOp() const {
180180
return opType == kOpSimple;
181181
}
182182

183-
bool Expr::isSimpleOp(char op) {
183+
bool Expr::isSimpleOp(char op) const {
184184
return isSimpleOp() && opChar == op;
185185
}
186186

‎src/sql/Expr.h‎

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace hsql {
3636
kOpCase,
3737

3838
// Binary operators.
39-
// Simple operators are identified by the opChar field (e.g. =, >, <).
39+
// Simple operators are identified by the opChar field (e.g. +, -, =, >, <).
4040
kOpSimple,
4141

4242
kOpNotEquals,
@@ -60,13 +60,9 @@ namespace hsql {
6060
// Represents SQL expressions (i.e. literals, operators, column_refs).
6161
// TODO: When destructing a placeholder expression, we might need to alter the placeholder_list.
6262
struct Expr {
63-
64-
Expr(ExprType type);
6563

66-
// Interesting side-effect:
67-
// Making the destructor virtual used to cause segmentation faults.
68-
// TODO: inspect.
69-
~Expr();
64+
Expr(ExprType type);
65+
virtual ~Expr();
7066

7167
ExprType type;
7268

@@ -89,19 +85,19 @@ namespace hsql {
8985

9086
// Convenience accessor methods.
9187

92-
bool isType(ExprType e_type);
88+
bool isType(ExprType exprType) const;
9389

94-
bool isLiteral();
90+
bool isLiteral() const;
9591

96-
bool hasAlias();
92+
bool hasAlias() const;
9793

98-
bool hasTable();
94+
bool hasTable() const;
9995

100-
char* getName();
96+
const char* getName() const;
10197

102-
bool isSimpleOp();
98+
bool isSimpleOp() const;
10399

104-
bool isSimpleOp(char op);
100+
bool isSimpleOp(char op) const;
105101

106102

107103
// Static constructors.

‎src/sql/SelectStatement.h‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace hsql {
1313

1414
/**
1515
* Description of the order by clause within a select statement
16-
* TODO: hold multiple expressions to be sorted by
1716
*/
1817
struct OrderDescription {
1918
OrderDescription(OrderType type, Expr* expr);
@@ -41,8 +40,7 @@ namespace hsql {
4140
*/
4241
struct GroupByDescription {
4342
GroupByDescription();
44-
// TODO: make virtual
45-
~GroupByDescription();
43+
virtual ~GroupByDescription();
4644

4745
std::vector<Expr*>* columns;
4846
Expr* having;

‎src/sql/Table.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ namespace hsql {
3535
JoinDefinition* join;
3636

3737
// Returns true if a schema is set.
38-
bool hasSchema();
38+
bool hasSchema() const;
3939

4040
// Returns the alias, if it is set. Otherwise the name.
41-
char* getName();
41+
const char* getName() const;
4242
};
4343

4444
// Possible types of joins.

‎src/sql/statements.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,11 @@ namespace hsql {
268268
}
269269
}
270270

271-
bool TableRef::hasSchema() {
271+
bool TableRef::hasSchema() const {
272272
return schema != NULL;
273273
}
274274

275-
char* TableRef::getName() {
275+
const char* TableRef::getName() const {
276276
if (alias != NULL) return alias;
277277
else return name;
278278
}

0 commit comments

Comments
 (0)