Skip to content

Commit 988dd5d

Browse files
committed
Update format
1 parent 07cb16a commit 988dd5d

8 files changed

+184
-123
lines changed

src/condition.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ extern "C" {
77

88
#include <Rinternals.h>
99

10-
static SEXP signal_condition(const char *msg, const char *class_,
11-
SEXP env = R_GlobalEnv) {
10+
static SEXP
11+
signal_condition(const char* msg, const char* class_, SEXP env = R_GlobalEnv) {
1212
SEXP condition, c, signalConditionFun, out;
1313

14-
const char *nms[] = {"message", ""};
14+
const char* nms[] = {"message", ""};
1515
PROTECT(condition = Rf_mkNamed(VECSXP, nms));
1616

1717
PROTECT(c = Rf_allocVector(STRSXP, 2));

src/connection.cpp

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,48 @@ Rcpp::DataFrame list_drivers_() {
1111
std::vector<std::string> names;
1212
std::vector<std::string> attributes;
1313
std::vector<std::string> values;
14-
for (auto &driver : nanodbc::list_drivers()) {
14+
for (auto& driver : nanodbc::list_drivers()) {
1515
if (driver.attributes.size() == 0) {
1616
names.push_back(driver.name);
1717
attributes.push_back("");
1818
values.push_back("");
1919
} else {
20-
for (auto &attr : driver.attributes) {
20+
for (auto& attr : driver.attributes) {
2121
names.push_back(driver.name);
2222
attributes.push_back(attr.keyword);
2323
values.push_back(attr.value);
2424
}
2525
}
2626
}
2727
return Rcpp::DataFrame::create(
28-
Rcpp::_["name"] = names, Rcpp::_["attribute"] = attributes,
29-
Rcpp::_["value"] = values, Rcpp::_["stringsAsFactors"] = false);
28+
Rcpp::_["name"] = names,
29+
Rcpp::_["attribute"] = attributes,
30+
Rcpp::_["value"] = values,
31+
Rcpp::_["stringsAsFactors"] = false);
3032
}
3133

3234
// [[Rcpp::export]]
3335
Rcpp::DataFrame list_data_sources_() {
3436
std::vector<std::string> names;
3537
std::vector<std::string> descriptions;
36-
for (auto &data_source : nanodbc::list_data_sources()) {
38+
for (auto& data_source : nanodbc::list_data_sources()) {
3739
names.push_back(data_source.name);
3840
descriptions.push_back(data_source.description);
3941
}
40-
return Rcpp::DataFrame::create(Rcpp::_["name"] = names,
41-
Rcpp::_["description"] = descriptions,
42-
Rcpp::_["stringsAsFactors"] = false);
42+
return Rcpp::DataFrame::create(
43+
Rcpp::_["name"] = names,
44+
Rcpp::_["description"] = descriptions,
45+
Rcpp::_["stringsAsFactors"] = false);
4346
}
4447

4548
// [[Rcpp::export]]
46-
connection_ptr odbc_connect(std::string const &connection_string,
47-
std::string const &timezone = "") {
49+
connection_ptr odbc_connect(
50+
std::string const& connection_string, std::string const& timezone = "") {
4851
return connection_ptr(new std::shared_ptr<odbc_connection>(
4952
new odbc_connection(connection_string, timezone)));
5053
}
5154

52-
std::string get_info_or_empty(connection_ptr const &p, short type) {
55+
std::string get_info_or_empty(connection_ptr const& p, short type) {
5356
try {
5457
return (*p)->connection()->get_info<std::string>(type);
5558
} catch (nanodbc::database_error c) {
@@ -58,13 +61,14 @@ std::string get_info_or_empty(connection_ptr const &p, short type) {
5861
}
5962

6063
// [[Rcpp::export]]
61-
Rcpp::List connection_info(connection_ptr const &p) {
64+
Rcpp::List connection_info(connection_ptr const& p) {
6265
return Rcpp::List::create(
6366
Rcpp::_["dbname"] = get_info_or_empty(p, SQL_DATABASE_NAME),
6467
Rcpp::_["dbms.name"] = get_info_or_empty(p, SQL_DBMS_NAME),
6568
Rcpp::_["db.version"] = get_info_or_empty(p, SQL_DBMS_VER),
6669
Rcpp::_["username"] = get_info_or_empty(p, SQL_USER_NAME),
67-
Rcpp::_["host"] = "", Rcpp::_["port"] = "",
70+
Rcpp::_["host"] = "",
71+
Rcpp::_["port"] = "",
6872
Rcpp::_["sourcename"] = get_info_or_empty(p, SQL_DATA_SOURCE_NAME),
6973
Rcpp::_["servername"] = get_info_or_empty(p, SQL_SERVER_NAME),
7074
Rcpp::_["drivername"] = get_info_or_empty(p, SQL_DRIVER_NAME),
@@ -75,38 +79,40 @@ Rcpp::List connection_info(connection_ptr const &p) {
7579
}
7680

7781
// [[Rcpp::export]]
78-
std::string connection_quote(connection_ptr const &p) {
82+
std::string connection_quote(connection_ptr const& p) {
7983
return get_info_or_empty(p, SQL_IDENTIFIER_QUOTE_CHAR);
8084
}
8185

8286
// [[Rcpp::export]]
8387
void connection_release(connection_ptr p) {
8488
if (p.get() != nullptr && (*p)->has_active_result()) {
8589
Rcpp::warning(
86-
"%s\n%s", "There is a result object still in use.",
90+
"%s\n%s",
91+
"There is a result object still in use.",
8792
"The connection will be automatically released when it is closed");
8893
}
8994
p.release();
9095
}
9196

9297
// [[Rcpp::export]]
93-
void connection_begin(connection_ptr const &p) { (*p)->begin(); }
98+
void connection_begin(connection_ptr const& p) { (*p)->begin(); }
9499

95100
// [[Rcpp::export]]
96-
void connection_commit(connection_ptr const &p) { (*p)->commit(); }
101+
void connection_commit(connection_ptr const& p) { (*p)->commit(); }
97102

98103
// [[Rcpp::export]]
99-
void connection_rollback(connection_ptr const &p) { (*p)->rollback(); }
104+
void connection_rollback(connection_ptr const& p) { (*p)->rollback(); }
100105

101106
// [[Rcpp::export]]
102-
bool connection_valid(connection_ptr const &p) { return p.get() != nullptr; }
107+
bool connection_valid(connection_ptr const& p) { return p.get() != nullptr; }
103108

104109
// [[Rcpp::export]]
105-
Rcpp::DataFrame connection_sql_tables(connection_ptr const &p,
106-
std::string const &catalog_name = "",
107-
std::string const &schema_name = "",
108-
std::string const &table_name = "",
109-
std::string const &table_type = "") {
110+
Rcpp::DataFrame connection_sql_tables(
111+
connection_ptr const& p,
112+
std::string const& catalog_name = "",
113+
std::string const& schema_name = "",
114+
std::string const& table_name = "",
115+
std::string const& table_type = "") {
110116
auto c = nanodbc::catalog(*(*p)->connection());
111117
auto tables =
112118
c.find_tables(table_name, table_type, schema_name, catalog_name);
@@ -124,18 +130,22 @@ Rcpp::DataFrame connection_sql_tables(connection_ptr const &p,
124130
catalog.push_back(tables.table_catalog());
125131
}
126132
return Rcpp::DataFrame::create(
127-
Rcpp::_["table_catalog"] = catalog, Rcpp::_["table_name"] = names,
128-
Rcpp::_["table_type"] = types, Rcpp::_["table_schema"] = schemas,
129-
Rcpp::_["table_remarks"] = remarks, Rcpp::_["stringsAsFactors"] = false);
133+
Rcpp::_["table_catalog"] = catalog,
134+
Rcpp::_["table_name"] = names,
135+
Rcpp::_["table_type"] = types,
136+
Rcpp::_["table_schema"] = schemas,
137+
Rcpp::_["table_remarks"] = remarks,
138+
Rcpp::_["stringsAsFactors"] = false);
130139
}
131140

132141
// "%" is a wildcard for all possible values
133142
// [[Rcpp::export]]
134-
Rcpp::DataFrame connection_sql_columns(connection_ptr const &p,
135-
std::string const &column_name = "",
136-
std::string const &catalog_name = "",
137-
std::string const &schema_name = "",
138-
std::string const &table_name = "") {
143+
Rcpp::DataFrame connection_sql_columns(
144+
connection_ptr const& p,
145+
std::string const& column_name = "",
146+
std::string const& catalog_name = "",
147+
std::string const& schema_name = "",
148+
std::string const& table_name = "") {
139149
auto c = nanodbc::catalog(*(*p)->connection());
140150
auto tables =
141151
c.find_columns(column_name, table_name, schema_name, catalog_name);
@@ -151,6 +161,8 @@ Rcpp::DataFrame connection_sql_columns(connection_ptr const &p,
151161
nullable.push_back(static_cast<bool>(tables.nullable()));
152162
}
153163
return Rcpp::DataFrame::create(
154-
Rcpp::_["name"] = names, Rcpp::_["field.type"] = field_type,
155-
Rcpp::_["nullable"] = nullable, Rcpp::_["stringsAsFactors"] = false);
164+
Rcpp::_["name"] = names,
165+
Rcpp::_["field.type"] = field_type,
166+
Rcpp::_["nullable"] = nullable,
167+
Rcpp::_["stringsAsFactors"] = false);
156168
}

src/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <Rinternals.h>
44
#include <stdlib.h> // for NULL
55

6-
void R_init_odbc(DllInfo *info) {
6+
void R_init_odbc(DllInfo* info) {
77
R_registerRoutines(info, NULL, NULL, NULL, NULL);
88
R_useDynamicSymbols(info, TRUE);
99
}

src/integer64.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
#define NA_INTEGER64 (0x8000000000000000)
44

5-
inline int64_t *INTEGER64(SEXP x) {
6-
return reinterpret_cast<int64_t *>(REAL(x));
5+
inline int64_t* INTEGER64(SEXP x) {
6+
return reinterpret_cast<int64_t*>(REAL(x));
77
}

src/odbc_connection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "odbc_connection.h"
22
#include "odbc_result.h"
33

4-
void odbc::odbc_connection::set_current_result(odbc_result *r) {
4+
void odbc::odbc_connection::set_current_result(odbc_result* r) {
55
if (r == current_result_) {
66
return;
77
}

src/odbc_connection.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,21 @@ class odbc_connection {
4848
t_->rollback();
4949
}
5050
bool has_active_result() const { return current_result_ != nullptr; }
51-
bool is_current_result(odbc_result *result) const {
51+
bool is_current_result(odbc_result* result) const {
5252
return current_result_ == result;
5353
}
5454
bool supports_transactions() const {
5555
return c_->get_info<unsigned short>(SQL_TXN_CAPABLE) != SQL_TC_NONE;
5656
}
5757

58-
void set_current_result(odbc_result *r);
58+
void set_current_result(odbc_result* r);
5959

6060
cctz::time_zone timezone() const { return timezone_; }
6161

6262
private:
6363
std::shared_ptr<nanodbc::connection> c_;
6464
std::unique_ptr<nanodbc::transaction> t_;
65-
odbc_result *current_result_;
65+
odbc_result* current_result_;
6666
cctz::time_zone timezone_;
6767
};
6868
}

0 commit comments

Comments
 (0)