HyriseSQLParser/src/SQLParserResult.h

65 lines
1.8 KiB
C
Raw Normal View History

#ifndef __SQLPARSERRESULT__
#define __SQLPARSERRESULT__
#include "sql/SQLStatement.h"
namespace hsql {
// Represents the result of the SQLParser.
// If parsing was successful it contains a list of SQLStatement.
class SQLParserResult {
public:
// Initialize with empty statement list.
SQLParserResult();
// Initialize with a single statement.
2017-02-08 02:59:07 +01:00
// Takes ownership of the statement.
SQLParserResult(SQLStatement* stmt);
// Deletes all statements in the resul.
virtual ~SQLParserResult();
2016-02-27 15:01:06 +01:00
2017-02-08 02:59:07 +01:00
// Returns true if parsing was successful.
bool isValid() const;
// Returns the number of statements in the result.
2017-02-08 02:59:07 +01:00
size_t size() const;
// Returns the error message, if an error occurred.
const char* errorMsg() const;
// Returns the line number of the occurrance of the error in the query.
int errorLine() const;
// Returns the column number of the occurrance of the error in the query.
int errorColumn() const;
2016-02-27 15:01:06 +01:00
// Gets the SQL statement with the given index.
2017-02-08 02:59:07 +01:00
const SQLStatement* getStatement(int index) const;
// Gets the non const SQL statement with the given index.
SQLStatement* getMutableStatement(int index);
2016-02-27 15:01:06 +01:00
// Adds a statement to the result list of statements.
2017-02-08 02:59:07 +01:00
// Takes ownership of the statement.
void addStatement(SQLStatement* stmt);
2016-02-27 15:01:06 +01:00
2017-02-08 02:59:07 +01:00
private:
// List of statements within the result.
2017-02-08 02:59:07 +01:00
std::vector<SQLStatement*> statements_;
// Flag indicating the parsing was successful.
2017-02-08 02:59:07 +01:00
bool isValid_;
2016-02-27 15:01:06 +01:00
// Error message, if an error occurred.
2017-02-08 02:59:07 +01:00
const char* errorMsg_;
// Line number of the occurrance of the error in the query.
2017-02-08 02:59:07 +01:00
int errorLine_;
// Column number of the occurrance of the error in the query.
2017-02-08 02:59:07 +01:00
int errorColumn_;
};
2016-02-27 14:45:59 +01:00
} // namespace hsql
#endif // __SQLPARSERRESULT__