Skip to content

Commit 183e10f

Browse files
author
Michael Penick
committed
Run clang-format
1 parent 4762815 commit 183e10f

569 files changed

Lines changed: 17783 additions & 21836 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cpp-driver/examples/async/async.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
*/
2727

2828
#include <assert.h>
29-
#include <string.h>
3029
#include <stdio.h>
3130
#include <stdlib.h>
31+
#include <string.h>
3232

3333
#include "cassandra.h"
3434

@@ -41,7 +41,6 @@ void print_error(CassFuture* future) {
4141
fprintf(stderr, "Error: %.*s\n", (int)message_length, message);
4242
}
4343

44-
4544
CassCluster* create_cluster(const char* hosts) {
4645
CassCluster* cluster = cass_cluster_new();
4746
cass_cluster_set_contact_points(cluster, hosts);
@@ -90,7 +89,7 @@ void insert_into_async(CassSession* session, const char* key) {
9089

9190
size_t i;
9291
for (i = 0; i < NUM_CONCURRENT_REQUESTS; ++i) {
93-
char key_buffer[64];
92+
char key_buffer[64];
9493
statement = cass_statement_new(query, 6);
9594

9695
sprintf(key_buffer, "%s%u", key, (unsigned int)i);
@@ -135,13 +134,10 @@ int main(int argc, char* argv[]) {
135134
return -1;
136135
}
137136

138-
execute_query(session,
139-
"CREATE KEYSPACE examples WITH replication = { \
137+
execute_query(session, "CREATE KEYSPACE examples WITH replication = { \
140138
'class': 'SimpleStrategy', 'replication_factor': '3' };");
141139

142-
143-
execute_query(session,
144-
"CREATE TABLE examples.async (key text, \
140+
execute_query(session, "CREATE TABLE examples.async (key text, \
145141
bln boolean, \
146142
flt float, dbl double,\
147143
i32 int, i64 bigint, \

cpp-driver/examples/auth/auth.c

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ typedef struct Credentials_ {
3535
const char* username;
3636
} Credentials;
3737

38-
void on_auth_initial(CassAuthenticator* auth,
39-
void* data) {
38+
void on_auth_initial(CassAuthenticator* auth, void* data) {
4039
/*
4140
* This callback is used to initiate a request to begin an authentication
4241
* exchange. Required resources can be acquired and initialized here.
@@ -52,7 +51,7 @@ void on_auth_initial(CassAuthenticator* auth,
5251
* authentication callbacks were set and is available to all
5352
* authentication exchanges.
5453
*/
55-
const Credentials* credentials = (const Credentials *)data;
54+
const Credentials* credentials = (const Credentials*)data;
5655

5756
size_t username_size = strlen(credentials->username);
5857
size_t password_size = strlen(credentials->password);
@@ -68,20 +67,14 @@ void on_auth_initial(CassAuthenticator* auth,
6867
memcpy(response + username_size + 2, credentials->password, password_size);
6968
}
7069

71-
void on_auth_challenge(CassAuthenticator* auth,
72-
void* data,
73-
const char* token,
74-
size_t token_size) {
70+
void on_auth_challenge(CassAuthenticator* auth, void* data, const char* token, size_t token_size) {
7571
/*
7672
* Not used for plain text authentication, but this is to be used
7773
* for handling an authentication challenge initiated by the server.
7874
*/
7975
}
8076

81-
void on_auth_success(CassAuthenticator* auth,
82-
void* data,
83-
const char* token,
84-
size_t token_size ) {
77+
void on_auth_success(CassAuthenticator* auth, void* data, const char* token, size_t token_size) {
8578
/*
8679
* Not used for plain text authentication, but this is to be used
8780
* for handling the success phase of an exchange.
@@ -104,17 +97,10 @@ int main(int argc, char* argv[]) {
10497
char* hosts = "127.0.0.1,127.0.0.2,127.0.0.3";
10598

10699
/* Setup authentication callbacks and credentials */
107-
CassAuthenticatorCallbacks auth_callbacks = {
108-
on_auth_initial,
109-
on_auth_challenge,
110-
on_auth_success,
111-
on_auth_cleanup
112-
};
113-
114-
Credentials credentials = {
115-
"cassandra",
116-
"cassandra"
117-
};
100+
CassAuthenticatorCallbacks auth_callbacks = { on_auth_initial, on_auth_challenge, on_auth_success,
101+
on_auth_cleanup };
102+
103+
Credentials credentials = { "cassandra", "cassandra" };
118104

119105
/* Add contact points */
120106
if (argc > 1) {
@@ -123,10 +109,7 @@ int main(int argc, char* argv[]) {
123109
cass_cluster_set_contact_points(cluster, hosts);
124110

125111
/* Set custom authentication callbacks and credentials */
126-
cass_cluster_set_authenticator_callbacks(cluster,
127-
&auth_callbacks,
128-
NULL,
129-
&credentials);
112+
cass_cluster_set_authenticator_callbacks(cluster, &auth_callbacks, NULL, &credentials);
130113

131114
/* Provide the cluster object as configuration to connect the session */
132115
connect_future = cass_session_connect(session, cluster);
@@ -138,8 +121,7 @@ int main(int argc, char* argv[]) {
138121
const char* message;
139122
size_t message_length;
140123
cass_future_error_message(connect_future, &message, &message_length);
141-
fprintf(stderr, "Unable to connect: '%.*s'\n", (int)message_length,
142-
message);
124+
fprintf(stderr, "Unable to connect: '%.*s'\n", (int)message_length, message);
143125
}
144126

145127
cass_future_free(connect_future);

cpp-driver/examples/basic/basic.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
*/
2727

2828
#include <assert.h>
29-
#include <string.h>
3029
#include <stdio.h>
3130
#include <stdlib.h>
31+
#include <string.h>
3232

3333
#include "cassandra.h"
3434

@@ -92,7 +92,8 @@ CassError insert_into_basic(CassSession* session, const char* key, const Basic*
9292
CassError rc = CASS_OK;
9393
CassStatement* statement = NULL;
9494
CassFuture* future = NULL;
95-
const char* query = "INSERT INTO examples.basic (key, bln, flt, dbl, i32, i64) VALUES (?, ?, ?, ?, ?, ?);";
95+
const char* query =
96+
"INSERT INTO examples.basic (key, bln, flt, dbl, i32, i64) VALUES (?, ?, ?, ?, ?, ?);";
9697

9798
statement = cass_statement_new(query, 6);
9899

@@ -175,13 +176,10 @@ int main(int argc, char* argv[]) {
175176
return -1;
176177
}
177178

178-
execute_query(session,
179-
"CREATE KEYSPACE examples WITH replication = { \
179+
execute_query(session, "CREATE KEYSPACE examples WITH replication = { \
180180
'class': 'SimpleStrategy', 'replication_factor': '3' };");
181181

182-
183-
execute_query(session,
184-
"CREATE TABLE examples.basic (key text, \
182+
execute_query(session, "CREATE TABLE examples.basic (key text, \
185183
bln boolean, \
186184
flt float, dbl double,\
187185
i32 int, i64 bigint, \

cpp-driver/examples/batch/batch.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
*/
2727

2828
#include <assert.h>
29-
#include <string.h>
3029
#include <stdio.h>
3130
#include <stdlib.h>
31+
#include <string.h>
3232

3333
#include "cassandra.h"
3434

3535
struct Pair_ {
36-
const char* key;
37-
const char* value;
36+
const char* key;
37+
const char* value;
3838
};
3939

4040
typedef struct Pair_ Pair;
@@ -105,7 +105,8 @@ CassError prepare_insert_into_batch(CassSession* session, const CassPrepared** p
105105
return rc;
106106
}
107107

108-
CassError insert_into_batch_with_prepared(CassSession* session, const CassPrepared* prepared, const Pair* pairs) {
108+
CassError insert_into_batch_with_prepared(CassSession* session, const CassPrepared* prepared,
109+
const Pair* pairs) {
109110
CassError rc = CASS_OK;
110111
CassFuture* future = NULL;
111112
CassBatch* batch = cass_batch_new(CASS_BATCH_TYPE_LOGGED);
@@ -120,13 +121,15 @@ CassError insert_into_batch_with_prepared(CassSession* session, const CassPrepar
120121
}
121122

122123
{
123-
CassStatement* statement = cass_statement_new("INSERT INTO examples.pairs (key, value) VALUES ('c', '3')", 0);
124+
CassStatement* statement =
125+
cass_statement_new("INSERT INTO examples.pairs (key, value) VALUES ('c', '3')", 0);
124126
cass_batch_add_statement(batch, statement);
125127
cass_statement_free(statement);
126128
}
127129

128130
{
129-
CassStatement* statement = cass_statement_new("INSERT INTO examples.pairs (key, value) VALUES (?, ?)", 2);
131+
CassStatement* statement =
132+
cass_statement_new("INSERT INTO examples.pairs (key, value) VALUES (?, ?)", 2);
130133
cass_statement_bind_string(statement, 0, "d");
131134
cass_statement_bind_string(statement, 1, "4");
132135
cass_batch_add_statement(batch, statement);
@@ -147,14 +150,13 @@ CassError insert_into_batch_with_prepared(CassSession* session, const CassPrepar
147150
return rc;
148151
}
149152

150-
151153
int main(int argc, char* argv[]) {
152154
CassCluster* cluster = NULL;
153155
CassSession* session = cass_session_new();
154156
const CassPrepared* prepared = NULL;
155157
char* hosts = "127.0.0.1";
156158

157-
Pair pairs[] = { {"a", "1"}, {"b", "2"}, { NULL, NULL} };
159+
Pair pairs[] = { { "a", "1" }, { "b", "2" }, { NULL, NULL } };
158160

159161
if (argc > 1) {
160162
hosts = argv[1];
@@ -167,13 +169,10 @@ int main(int argc, char* argv[]) {
167169
return -1;
168170
}
169171

170-
execute_query(session,
171-
"CREATE KEYSPACE examples WITH replication = { \
172+
execute_query(session, "CREATE KEYSPACE examples WITH replication = { \
172173
'class': 'SimpleStrategy', 'replication_factor': '3' };");
173174

174-
175-
execute_query(session,
176-
"CREATE TABLE examples.pairs (key text, \
175+
execute_query(session, "CREATE TABLE examples.pairs (key text, \
177176
value text, \
178177
PRIMARY KEY (key));");
179178

cpp-driver/examples/bind_by_name/bind_by_name.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
*/
2727

2828
#include <assert.h>
29-
#include <string.h>
3029
#include <stdio.h>
3130
#include <stdlib.h>
31+
#include <string.h>
3232

3333
#include "cassandra.h"
3434

@@ -106,7 +106,8 @@ CassError prepare_query(CassSession* session, const char* query, const CassPrepa
106106
return rc;
107107
}
108108

109-
CassError insert_into_basic(CassSession* session, const CassPrepared* prepared, const char* key, const Basic* basic) {
109+
CassError insert_into_basic(CassSession* session, const CassPrepared* prepared, const char* key,
110+
const Basic* basic) {
110111
CassError rc = CASS_OK;
111112
CassStatement* statement = NULL;
112113
CassFuture* future = NULL;
@@ -135,7 +136,8 @@ CassError insert_into_basic(CassSession* session, const CassPrepared* prepared,
135136
return rc;
136137
}
137138

138-
CassError select_from_basic(CassSession* session, const CassPrepared * prepared, const char* key, Basic* basic) {
139+
CassError select_from_basic(CassSession* session, const CassPrepared* prepared, const char* key,
140+
Basic* basic) {
139141
CassError rc = CASS_OK;
140142
CassStatement* statement = NULL;
141143
CassFuture* future = NULL;
@@ -183,10 +185,9 @@ int main(int argc, char* argv[]) {
183185
const CassPrepared* select_prepared = NULL;
184186
char* hosts = "127.0.0.1";
185187

186-
const char* insert_query
187-
= "INSERT INTO examples.basic (key, bln, flt, dbl, i32, i64) VALUES (?, ?, ?, ?, ?, ?);";
188-
const char* select_query
189-
= "SELECT * FROM examples.basic WHERE key = ?";
188+
const char* insert_query =
189+
"INSERT INTO examples.basic (key, bln, flt, dbl, i32, i64) VALUES (?, ?, ?, ?, ?, ?);";
190+
const char* select_query = "SELECT * FROM examples.basic WHERE key = ?";
190191

191192
if (argc > 1) {
192193
hosts = argv[1];
@@ -199,25 +200,21 @@ int main(int argc, char* argv[]) {
199200
return -1;
200201
}
201202

202-
execute_query(session,
203-
"CREATE KEYSPACE examples WITH replication = { \
203+
execute_query(session, "CREATE KEYSPACE examples WITH replication = { \
204204
'class': 'SimpleStrategy', 'replication_factor': '3' };");
205205

206-
207-
execute_query(session,
208-
"CREATE TABLE examples.basic (key text, \
206+
execute_query(session, "CREATE TABLE examples.basic (key text, \
209207
bln boolean, \
210208
flt float, dbl double,\
211209
i32 int, i64 bigint, \
212210
PRIMARY KEY (key));");
213211

214-
215212
if (prepare_query(session, insert_query, &insert_prepared) == CASS_OK) {
216213
insert_into_basic(session, insert_prepared, "prepared_test", &input);
217214
cass_prepared_free(insert_prepared);
218215
}
219216

220-
if (prepare_query(session, select_query, &select_prepared) == CASS_OK) {
217+
if (prepare_query(session, select_query, &select_prepared) == CASS_OK) {
221218
select_from_basic(session, select_prepared, "prepared_test", &output);
222219

223220
assert(input.bln == output.bln);

cpp-driver/examples/callbacks/callbacks.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
*/
2727

2828
#include <assert.h>
29-
#include <string.h>
3029
#include <stdio.h>
3130
#include <stdlib.h>
31+
#include <string.h>
3232

3333
#include <uv.h>
3434

@@ -76,14 +76,14 @@ CassCluster* create_cluster(const char* hosts) {
7676
return cluster;
7777
}
7878

79-
void connect_session(CassSession* session, const CassCluster* cluster, CassFutureCallback callback) {
79+
void connect_session(CassSession* session, const CassCluster* cluster,
80+
CassFutureCallback callback) {
8081
CassFuture* future = cass_session_connect(session, cluster);
8182
cass_future_set_callback(future, callback, session);
8283
cass_future_free(future);
8384
}
8485

85-
void execute_query(CassSession* session, const char* query,
86-
CassFutureCallback callback) {
86+
void execute_query(CassSession* session, const char* query, CassFutureCallback callback) {
8787
CassStatement* statement = cass_statement_new(query, 0);
8888
CassFuture* future = cass_session_execute(session, statement);
8989
cass_future_set_callback(future, callback, session);
@@ -113,9 +113,7 @@ void on_create_keyspace(CassFuture* future, void* data) {
113113
print_error(future);
114114
}
115115

116-
execute_query((CassSession*)data,
117-
"USE examples",
118-
on_set_keyspace);
116+
execute_query((CassSession*)data, "USE examples", on_set_keyspace);
119117
}
120118

121119
void on_set_keyspace(CassFuture* future, void* data) {
@@ -163,10 +161,8 @@ void on_insert(CassFuture* future, void* data) {
163161
signal_exit();
164162
} else {
165163
const char* select_query = "SELECT * FROM callbacks";
166-
CassStatement* statement
167-
= cass_statement_new(select_query, 0);
168-
CassFuture* select_future
169-
= cass_session_execute((CassSession*)data, statement);
164+
CassStatement* statement = cass_statement_new(select_query, 0);
165+
CassFuture* select_future = cass_session_execute((CassSession*)data, statement);
170166

171167
cass_future_set_callback(select_future, on_select, data);
172168

0 commit comments

Comments
 (0)