2016-02-27 14:24:23 +01:00
|
|
|
|
2016-02-27 14:45:59 +01:00
|
|
|
#include "SQLParserResult.h"
|
|
|
|
|
|
|
|
namespace hsql {
|
|
|
|
|
2017-02-08 02:06:15 +01:00
|
|
|
SQLParserResult::SQLParserResult() :
|
2017-04-08 02:37:30 +02:00
|
|
|
isValid_(false),
|
2017-02-08 02:59:07 +01:00
|
|
|
errorMsg_(NULL) {};
|
2016-02-27 14:45:59 +01:00
|
|
|
|
2017-02-08 02:06:15 +01:00
|
|
|
SQLParserResult::SQLParserResult(SQLStatement* stmt) :
|
2017-04-08 02:37:30 +02:00
|
|
|
isValid_(false),
|
2017-02-08 02:59:07 +01:00
|
|
|
errorMsg_(NULL) {
|
2017-02-08 02:06:15 +01:00
|
|
|
addStatement(stmt);
|
|
|
|
};
|
2016-02-27 14:45:59 +01:00
|
|
|
|
2017-04-21 16:15:07 +02:00
|
|
|
// Move constructor.
|
|
|
|
SQLParserResult::SQLParserResult(SQLParserResult&& moved) {
|
|
|
|
isValid_ = moved.isValid_;
|
|
|
|
errorMsg_ = moved.errorMsg_;
|
|
|
|
statements_ = std::move(moved.statements_);
|
|
|
|
|
|
|
|
moved.errorMsg_ = NULL;
|
|
|
|
moved.reset();
|
|
|
|
}
|
|
|
|
|
2017-02-08 02:06:15 +01:00
|
|
|
SQLParserResult::~SQLParserResult() {
|
2017-04-08 02:37:30 +02:00
|
|
|
reset();
|
2017-02-08 02:06:15 +01:00
|
|
|
}
|
2016-02-27 14:45:59 +01:00
|
|
|
|
2017-02-08 02:06:15 +01:00
|
|
|
void SQLParserResult::addStatement(SQLStatement* stmt) {
|
2017-02-08 02:59:07 +01:00
|
|
|
statements_.push_back(stmt);
|
2017-02-08 02:06:15 +01:00
|
|
|
}
|
2016-02-27 14:45:59 +01:00
|
|
|
|
2017-02-08 02:59:07 +01:00
|
|
|
const SQLStatement* SQLParserResult::getStatement(int index) const {
|
|
|
|
return statements_[index];
|
2017-02-08 02:06:15 +01:00
|
|
|
}
|
2016-02-27 14:45:59 +01:00
|
|
|
|
2017-02-08 02:59:07 +01:00
|
|
|
SQLStatement* SQLParserResult::getMutableStatement(int index) {
|
|
|
|
return statements_[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t SQLParserResult::size() const {
|
|
|
|
return statements_.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SQLParserResult::isValid() const {
|
|
|
|
return isValid_;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* SQLParserResult::errorMsg() const {
|
|
|
|
return errorMsg_;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SQLParserResult::errorLine() const {
|
|
|
|
return errorLine_;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SQLParserResult::errorColumn() const {
|
|
|
|
return errorColumn_;
|
2017-02-08 02:06:15 +01:00
|
|
|
}
|
2016-02-27 15:01:06 +01:00
|
|
|
|
2017-02-08 03:07:51 +01:00
|
|
|
void SQLParserResult::setIsValid(bool isValid) {
|
|
|
|
isValid_ = isValid;
|
|
|
|
}
|
|
|
|
|
2017-02-08 04:56:07 +01:00
|
|
|
void SQLParserResult::setErrorDetails(char* errorMsg, int errorLine, int errorColumn) {
|
2017-02-08 03:07:51 +01:00
|
|
|
errorMsg_ = errorMsg;
|
|
|
|
errorLine_ = errorLine;
|
|
|
|
errorColumn_ = errorColumn;
|
|
|
|
}
|
|
|
|
|
2017-04-08 02:37:30 +02:00
|
|
|
const std::vector<SQLStatement*>& SQLParserResult::getStatements() const {
|
|
|
|
return statements_;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<SQLStatement*> SQLParserResult::releaseStatements() {
|
|
|
|
std::vector<SQLStatement*> copy = statements_;
|
|
|
|
|
|
|
|
statements_.clear();
|
|
|
|
|
|
|
|
return copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SQLParserResult::reset() {
|
|
|
|
for (SQLStatement* statement : statements_) {
|
|
|
|
delete statement;
|
|
|
|
}
|
|
|
|
statements_.clear();
|
|
|
|
|
|
|
|
isValid_ = false;
|
|
|
|
|
|
|
|
free(errorMsg_);
|
|
|
|
errorMsg_ = NULL;
|
|
|
|
errorLine_ = -1;
|
|
|
|
errorColumn_ = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace hsql
|