You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

45 lines
1.3 KiB

#include "InsertStatementBuilder.h"
namespace db {
namespace statements {
namespace builder {
InsertStatementBuilder &InsertStatementBuilder::table(const std::string &table) {
m_statement.body += "INSERT INTO " + table + " ";
return *this;
}
InsertStatementBuilder &InsertStatementBuilder::columns(const std::string &cols) {
m_statement.body += "(" + cols + ")\n";
return *this;
}
InsertStatementBuilder &InsertStatementBuilder::values() {
m_statement.body += " VALUES ";
return *this;
}
InsertStatementBuilder &InsertStatementBuilder::row(const std::string &values) {
m_statement.body += " (" + values + "),\n";
return *this;
}
InsertStatementBuilder &InsertStatementBuilder::row(const std::vector<std::string> &values) {
m_statement.body += " (";
bool first = true;
for(auto const& v : values) {
if(first) { first = false; } else { m_statement.body += ","; }
m_statement.body += v;
}
m_statement.body += "),\n";
return *this;
}
InsertStatementBuilder &InsertStatementBuilder::close() {
m_statement.body.pop_back();
m_statement.body.pop_back();
m_statement.body += ";\n";
return *this;
}
}
}
}