Skip to content

Commit

Permalink
Merge branch 'f-#159-astyle'. Closes #159.
Browse files Browse the repository at this point in the history
- Use `astyle` for code formatting (#159).
  • Loading branch information
krlmlr committed Sep 1, 2016
2 parents 78a256e + 748640d commit 11de0a7
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 119 deletions.
6 changes: 3 additions & 3 deletions src/RSQLite_types.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __RSQLSITE_TYPES__
#define __RSQLSITE_TYPES__
#define __RSQLSITE_TYPES__

#include "SqliteResult.h"
#include "SqliteConnection.h"
#include "SqliteResult.h"
#include "SqliteConnection.h"

#endif // __RSQLSITE_TYPES__
30 changes: 16 additions & 14 deletions src/SqliteConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ typedef boost::shared_ptr<SqliteConnectionWrapper> SqliteConnectionPtr;
class SqliteConnectionWrapper : boost::noncopyable {
public:
// Create a new connection handle
SqliteConnectionWrapper(std::string path, bool allow_ext,
SqliteConnectionWrapper(std::string path, bool allow_ext,
int flags, std::string vfs = "")
: pConn_(NULL) {

// Get the underlying database connection
int rc = sqlite3_open_v2(path.c_str(), &pConn_, flags, vfs.size() ? vfs.c_str() : NULL);
if (rc != SQLITE_OK) {
Expand All @@ -33,11 +33,11 @@ class SqliteConnectionWrapper : boost::noncopyable {
sqlite3_enable_load_extension(pConn_, 1);
}
}

void copy_to(SqliteConnectionPtr pDest) {
sqlite3_backup* backup = sqlite3_backup_init(pDest->conn(), "main",
pConn_, "main");
sqlite3_backup* backup =
sqlite3_backup_init(pDest->conn(), "main", pConn_, "main");

int rc = sqlite3_backup_step(backup, -1);
if (rc != SQLITE_DONE) {
Rcpp::stop("Failed to copy all data:\n%s", getException());
Expand All @@ -47,17 +47,19 @@ class SqliteConnectionWrapper : boost::noncopyable {
Rcpp::stop("Could not finish copy:\n%s", getException());
}
}

virtual ~SqliteConnectionWrapper() {
try {
sqlite3_close_v2(pConn_);
} catch(...) {}
sqlite3_close_v2(pConn_);
} catch (...) {}
}


// Get access to the underlying sqlite3*
sqlite3* conn() const { return pConn_; }

sqlite3* conn() const {
return pConn_;
}

// Get the last exception code
int getExceptionCode() const {
if (pConn_ != NULL)
Expand All @@ -73,7 +75,7 @@ class SqliteConnectionWrapper : boost::noncopyable {
else
return std::string();
}

private:
sqlite3* pConn_;
};
Expand Down
Loading

0 comments on commit 11de0a7

Please sign in to comment.