HyriseSQLParser/src/SQLParserResult.cpp

89 lines
1.8 KiB
C++
Raw Normal View History

2016-02-27 14:45:59 +01:00
#include "SQLParserResult.h"
namespace hsql {
SQLParserResult::SQLParserResult() :
isValid_(false),
2017-02-08 02:59:07 +01:00
errorMsg_(NULL) {};
2016-02-27 14:45:59 +01:00
SQLParserResult::SQLParserResult(SQLStatement* stmt) :
isValid_(false),
2017-02-08 02:59:07 +01:00
errorMsg_(NULL) {
addStatement(stmt);
};
2016-02-27 14:45:59 +01:00
SQLParserResult::~SQLParserResult() {
reset();
}
2016-02-27 14:45:59 +01:00
void SQLParserResult::addStatement(SQLStatement* stmt) {
2017-02-08 02:59:07 +01:00
statements_.push_back(stmt);
}
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];
}
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_;
}
2016-02-27 15:01:06 +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) {
errorMsg_ = errorMsg;
errorLine_ = errorLine;
errorColumn_ = errorColumn;
}
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