summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdbpp/column.cpp5
-rw-r--r--libdbpp/connection.cpp13
-rw-r--r--libdbpp/mockDatabase.cpp5
-rw-r--r--libdbpp/selectcommand.cpp8
-rw-r--r--libdbpp/sqlParse.ll5
5 files changed, 22 insertions, 14 deletions
diff --git a/libdbpp/column.cpp b/libdbpp/column.cpp
index 2bb29d8..e7bbd21 100644
--- a/libdbpp/column.cpp
+++ b/libdbpp/column.cpp
@@ -1,7 +1,7 @@
#include "column.h"
#include <boost/utility/enable_if.hpp>
#include <exception>
-#include <buffer.h>
+#include <compileTimeFormatter.h>
namespace DB {
Column::Column(const Glib::ustring & n, unsigned int i) :
@@ -16,10 +16,11 @@ Column::~Column()
InvalidConversion::InvalidConversion(const char * const f, const char * const t) : from(f), to(t) { }
+AdHocFormatter(InvalidConversionMsg, "Invalid conversion from column type (%?) to value type (%?)");
std::string
InvalidConversion::message() const throw()
{
- return stringf("Invalid conversion from column type (%s) to value type (%s)", from, to);
+ return InvalidConversionMsg::get(from, to);
}
template<typename T>
diff --git a/libdbpp/connection.cpp b/libdbpp/connection.cpp
index 6d79bc2..98fc89b 100644
--- a/libdbpp/connection.cpp
+++ b/libdbpp/connection.cpp
@@ -3,7 +3,7 @@
#include "selectcommand.h"
#include "error.h"
#include <factory.impl.h>
-#include <buffer.h>
+#include <compileTimeFormatter.h>
#include <sqlParse.h>
#include <boost/shared_ptr.hpp>
#include <system_error>
@@ -55,11 +55,13 @@ DB::Connection::finish() const
}
}
+AdHocFormatter(SavePointFmt, "tx_sp_%?_%?");
+
void
DB::Connection::beginTx()
{
if (inTx()) {
- savepoint(stringbf("tx_sp_%p_%d", this, txOpenDepth));
+ savepoint(SavePointFmt::get(this, txOpenDepth));
}
else {
beginTxInt();
@@ -77,7 +79,7 @@ DB::Connection::commitTx()
commitTxInt();
break;
default:
- releaseSavepoint(stringbf("tx_sp_%p_%d", this, txOpenDepth - 1));
+ releaseSavepoint(SavePointFmt::get(this, txOpenDepth - 1));
break;
}
txOpenDepth -= 1;
@@ -93,7 +95,7 @@ DB::Connection::rollbackTx()
rollbackTxInt();
break;
default:
- rollbackToSavepoint(stringbf("tx_sp_%p_%d", this, txOpenDepth - 1));
+ rollbackToSavepoint(SavePointFmt::get(this, txOpenDepth - 1));
break;
}
txOpenDepth -= 1;
@@ -181,10 +183,11 @@ DB::Connection::bulkUploadData(FILE * in) const
}
+AdHocFormatter(PluginLibraryFormat, "libdbpp-%?.so");
boost::optional<std::string>
DB::Connection::resolvePlugin(const std::type_info &, const std::string & name)
{
- return stringbf("libdbpp-%s.so", name);
+ return PluginLibraryFormat::get(name);
}
int64_t
diff --git a/libdbpp/mockDatabase.cpp b/libdbpp/mockDatabase.cpp
index 52deb7e..8951189 100644
--- a/libdbpp/mockDatabase.cpp
+++ b/libdbpp/mockDatabase.cpp
@@ -1,5 +1,5 @@
#include "mockDatabase.h"
-#include <buffer.h>
+#include <compileTimeFormatter.h>
#include <fstream>
#include <modifycommand.h>
#include <plugins.impl.h>
@@ -68,10 +68,11 @@ MockDatabase::PlaySchemaScript(DB::Connection * conn, const boost::filesystem::p
f.close();
}
+AdHocFormatter(MockServerDatabaseName, "test_%?_%?");
MockServerDatabase::MockServerDatabase(const std::string & masterdb, const std::string & name, const std::string & type) :
MockDatabase(name),
master(DB::ConnectionFactory::createNew(type, masterdb)),
- testDbName(stringbf("test_%d_%d", getpid(), ++mocked))
+ testDbName(MockServerDatabaseName::get(getpid(), ++mocked))
{
}
diff --git a/libdbpp/selectcommand.cpp b/libdbpp/selectcommand.cpp
index 6f36aa5..fd0c58e 100644
--- a/libdbpp/selectcommand.cpp
+++ b/libdbpp/selectcommand.cpp
@@ -2,23 +2,25 @@
#include "error.h"
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
-#include <buffer.h>
+#include <compileTimeFormatter.h>
namespace DB {
ColumnIndexOutOfRange::ColumnIndexOutOfRange(unsigned int n) : colNo(n) { }
+ AdHocFormatter(ColumnIndexOutOfRangeMsg, "Column (%?) index out of range");
std::string
ColumnIndexOutOfRange::message() const throw()
{
- return stringf("Column (%u) index out of range", colNo);
+ return ColumnIndexOutOfRangeMsg::get(colNo);
}
ColumnDoesNotExist::ColumnDoesNotExist(const Glib::ustring & n) : colName(n) { }
+ AdHocFormatter(ColumnDoesNotExistMsg, "Column (%?) does not exist");
std::string
ColumnDoesNotExist::message() const throw()
{
- return stringf("Column (%s) does not exist", colName.c_str());
+ return ColumnDoesNotExistMsg::get(colName);
}
};
diff --git a/libdbpp/sqlParse.ll b/libdbpp/sqlParse.ll
index f33f311..3037c0a 100644
--- a/libdbpp/sqlParse.ll
+++ b/libdbpp/sqlParse.ll
@@ -9,7 +9,7 @@
%{
#include <stdexcept>
-#include <buffer.h>
+#include <compileTimeFormatter.h>
#include "sqlParse.h"
#pragma GCC diagnostic ignored "-Wsign-compare"
%}
@@ -136,10 +136,11 @@ scriptdir "$SCRIPTDIR"
namespace DB {
SqlParseException::SqlParseException(const char * r, unsigned int l) : reason(r), line(l) { }
+ AdHocFormatter(SqlParseExceptionMsg, "Error parsing SQL script: %? at line %?");
std::string
SqlParseException::message() const throw()
{
- return stringf("Error parsing SQL script: %s at line %u", reason, line);
+ return SqlParseExceptionMsg::get(reason, line);
}
SqlParse::SqlParse(std::istream & f, const boost::filesystem::path & s, Connection * c) :