summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/History')
-rw-r--r--Swiften/History/HistoryManager.h2
-rw-r--r--Swiften/History/HistoryMessage.h6
-rw-r--r--Swiften/History/SQLiteHistoryManager.cpp32
-rw-r--r--Swiften/History/SQLiteHistoryManager.h2
4 files changed, 21 insertions, 21 deletions
diff --git a/Swiften/History/HistoryManager.h b/Swiften/History/HistoryManager.h
index c6b80e5..c918cbc 100644
--- a/Swiften/History/HistoryManager.h
+++ b/Swiften/History/HistoryManager.h
@@ -6,7 +6,7 @@
#pragma once
-#include "Swiften/Base/String.h"
+#include <string>
#include "Swiften/JID/JID.h"
#include "Swiften/History/HistoryMessage.h"
diff --git a/Swiften/History/HistoryMessage.h b/Swiften/History/HistoryMessage.h
index bb605ee..5e4782d 100644
--- a/Swiften/History/HistoryMessage.h
+++ b/Swiften/History/HistoryMessage.h
@@ -11,10 +11,10 @@
namespace Swift {
class HistoryMessage {
public:
- HistoryMessage(const String& message, const JID& from, const JID& to, const boost::posix_time::ptime time) : message_(message), from_(from), to_(to), time_(time) {
+ HistoryMessage(const std::string& message, const JID& from, const JID& to, const boost::posix_time::ptime time) : message_(message), from_(from), to_(to), time_(time) {
}
- const String& getMessage() const {
+ const std::string& getMessage() const {
return message_;
}
@@ -35,7 +35,7 @@ namespace Swift {
}
private:
- String message_;
+ std::string message_;
JID from_;
JID to_;
boost::posix_time::ptime time_;
diff --git a/Swiften/History/SQLiteHistoryManager.cpp b/Swiften/History/SQLiteHistoryManager.cpp
index 43443c7..9d5a000 100644
--- a/Swiften/History/SQLiteHistoryManager.cpp
+++ b/Swiften/History/SQLiteHistoryManager.cpp
@@ -12,9 +12,9 @@
namespace {
-inline Swift::String getEscapedString(const Swift::String& s) {
- Swift::String result(s);
- result.replaceAll('\'', Swift::String("\\'"));
+inline Swift::std::string getEscapedString(const Swift::std::string& s) {
+ Swift::std::string result(s);
+ result.replaceAll('\'', Swift::std::string("\\'"));
return result;
}
@@ -23,8 +23,8 @@ inline Swift::String getEscapedString(const Swift::String& s) {
namespace Swift {
-SQLiteHistoryManager::SQLiteHistoryManager(const String& file) : db_(0) {
- sqlite3_open(file.getUTF8Data(), &db_);
+SQLiteHistoryManager::SQLiteHistoryManager(const std::string& file) : db_(0) {
+ sqlite3_open(file.c_str(), &db_);
if (!db_) {
std::cerr << "Error opening database " << file << std::endl; // FIXME
}
@@ -49,9 +49,9 @@ SQLiteHistoryManager::~SQLiteHistoryManager() {
void SQLiteHistoryManager::addMessage(const HistoryMessage& message) {
int secondsSinceEpoch = (message.getTime() - boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1))).total_seconds();
- String statement = String("INSERT INTO messages('from', 'to', 'message', 'time') VALUES(") + boost::lexical_cast<std::string>(getIDForJID(message.getFrom())) + ", " + boost::lexical_cast<std::string>(getIDForJID(message.getTo())) + ", '" + getEscapedString(message.getMessage()) + "', " + boost::lexical_cast<std::string>(secondsSinceEpoch) + ")";
+ std::string statement = std::string("INSERT INTO messages('from', 'to', 'message', 'time') VALUES(") + boost::lexical_cast<std::string>(getIDForJID(message.getFrom())) + ", " + boost::lexical_cast<std::string>(getIDForJID(message.getTo())) + ", '" + getEscapedString(message.getMessage()) + "', " + boost::lexical_cast<std::string>(secondsSinceEpoch) + ")";
char* errorMessage;
- int result = sqlite3_exec(db_, statement.getUTF8Data(), 0, 0, &errorMessage);
+ int result = sqlite3_exec(db_, statement.c_str(), 0, 0, &errorMessage);
if (result != SQLITE_OK) {
std::cerr << "SQL Error: " << errorMessage << std::endl;
sqlite3_free(errorMessage);
@@ -61,8 +61,8 @@ void SQLiteHistoryManager::addMessage(const HistoryMessage& message) {
std::vector<HistoryMessage> SQLiteHistoryManager::getMessages() const {
std::vector<HistoryMessage> result;
sqlite3_stmt* selectStatement;
- String selectQuery("SELECT messages.'from', messages.'to', messages.'message', messages.'time' FROM messages");
- int r = sqlite3_prepare(db_, selectQuery.getUTF8Data(), selectQuery.getUTF8Size(), &selectStatement, NULL);
+ std::string selectQuery("SELECT messages.'from', messages.'to', messages.'message', messages.'time' FROM messages");
+ int r = sqlite3_prepare(db_, selectQuery.c_str(), selectQuery.size(), &selectStatement, NULL);
if (r != SQLITE_OK) {
std::cout << "Error: " << sqlite3_errmsg(db_) << std::endl;
}
@@ -70,7 +70,7 @@ std::vector<HistoryMessage> SQLiteHistoryManager::getMessages() const {
while (r == SQLITE_ROW) {
boost::optional<JID> from(getJIDFromID(sqlite3_column_int(selectStatement, 0)));
boost::optional<JID> to(getJIDFromID(sqlite3_column_int(selectStatement, 1)));
- String message(reinterpret_cast<const char*>(sqlite3_column_text(selectStatement, 2)));
+ std::string message(reinterpret_cast<const char*>(sqlite3_column_text(selectStatement, 2)));
int secondsSinceEpoch(sqlite3_column_int(selectStatement, 3));
boost::posix_time::ptime time(boost::gregorian::date(1970, 1, 1), boost::posix_time::seconds(secondsSinceEpoch));
@@ -95,9 +95,9 @@ int SQLiteHistoryManager::getIDForJID(const JID& jid) {
}
int SQLiteHistoryManager::addJID(const JID& jid) {
- String statement = String("INSERT INTO jids('jid') VALUES('") + getEscapedString(jid.toString()) + "')";
+ std::string statement = std::string("INSERT INTO jids('jid') VALUES('") + getEscapedString(jid.toString()) + "')";
char* errorMessage;
- int result = sqlite3_exec(db_, statement.getUTF8Data(), 0, 0, &errorMessage);
+ int result = sqlite3_exec(db_, statement.c_str(), 0, 0, &errorMessage);
if (result != SQLITE_OK) {
std::cerr << "SQL Error: " << errorMessage << std::endl;
sqlite3_free(errorMessage);
@@ -108,8 +108,8 @@ int SQLiteHistoryManager::addJID(const JID& jid) {
boost::optional<JID> SQLiteHistoryManager::getJIDFromID(int id) const {
boost::optional<JID> result;
sqlite3_stmt* selectStatement;
- String selectQuery("SELECT jid FROM jids WHERE id=" + boost::lexical_cast<std::string>(id));
- int r = sqlite3_prepare(db_, selectQuery.getUTF8Data(), selectQuery.getUTF8Size(), &selectStatement, NULL);
+ std::string selectQuery("SELECT jid FROM jids WHERE id=" + boost::lexical_cast<std::string>(id));
+ int r = sqlite3_prepare(db_, selectQuery.c_str(), selectQuery.size(), &selectStatement, NULL);
if (r != SQLITE_OK) {
std::cout << "Error: " << sqlite3_errmsg(db_) << std::endl;
}
@@ -124,8 +124,8 @@ boost::optional<JID> SQLiteHistoryManager::getJIDFromID(int id) const {
boost::optional<int> SQLiteHistoryManager::getIDFromJID(const JID& jid) const {
boost::optional<int> result;
sqlite3_stmt* selectStatement;
- String selectQuery("SELECT id FROM jids WHERE jid='" + jid.toString() + "'");
- int r = sqlite3_prepare(db_, selectQuery.getUTF8Data(), selectQuery.getUTF8Size(), &selectStatement, NULL);
+ std::string selectQuery("SELECT id FROM jids WHERE jid='" + jid.toString() + "'");
+ int r = sqlite3_prepare(db_, selectQuery.c_str(), selectQuery.size(), &selectStatement, NULL);
if (r != SQLITE_OK) {
std::cout << "Error: " << sqlite3_errmsg(db_) << std::endl;
}
diff --git a/Swiften/History/SQLiteHistoryManager.h b/Swiften/History/SQLiteHistoryManager.h
index 5c8d153..a2b89f4 100644
--- a/Swiften/History/SQLiteHistoryManager.h
+++ b/Swiften/History/SQLiteHistoryManager.h
@@ -15,7 +15,7 @@ struct sqlite3;
namespace Swift {
class SQLiteHistoryManager : public HistoryManager {
public:
- SQLiteHistoryManager(const String& file);
+ SQLiteHistoryManager(const std::string& file);
~SQLiteHistoryManager();
virtual void addMessage(const HistoryMessage& message);