Skip to content

Commit 1a85e8b

Browse files
committed
minor: clang-format pass
1 parent d1583f6 commit 1a85e8b

22 files changed

+167
-175
lines changed

examples/bsoncxx/getting_values.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,6 @@ int main(int, char**) {
9090
};
9191

9292
// Make all variables used.
93-
return (awards && first_award_year && second_award_year && last_name) ?
94-
EXIT_SUCCESS : EXIT_FAILURE;
93+
return (awards && first_award_year && second_award_year && last_name) ? EXIT_SUCCESS
94+
: EXIT_FAILURE;
9595
}

examples/bsoncxx/view_and_value.cpp

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,10 @@ int main(int, char**) {
2525
using builder::basic::sub_array;
2626

2727
auto doc = builder::basic::document{};
28-
doc.append(kvp("team", "platforms"),
29-
kvp("id", types::b_oid{oid(oid::init_tag)}),
28+
doc.append(kvp("team", "platforms"), kvp("id", types::b_oid{oid(oid::init_tag)}),
3029
kvp("members", [](sub_array sa) {
31-
sa.append("tyler", "jason", "drew",
32-
"sam", "ernie", "john",
33-
"mark", "crystal");
34-
})
35-
);
30+
sa.append("tyler", "jason", "drew", "sam", "ernie", "john", "mark", "crystal");
31+
}));
3632

3733
// document::value is an owning bson document conceptually similar to string.
3834
document::value value{doc.extract()};
@@ -49,7 +45,6 @@ int main(int, char**) {
4945

5046
// iterate over the elements in a bson document
5147
for (document::element ele : view) {
52-
5348
// element is non owning view of a key-value pair within a document.
5449

5550
// we can use the key() method to get a string_view of the key.
@@ -59,31 +54,32 @@ int main(int, char**) {
5954

6055
// we can use type() to get the type of the value.
6156
switch (ele.type()) {
62-
case type::k_utf8:
63-
std::cout << "Got String!" << std::endl;
64-
break;
65-
case type::k_oid:
66-
std::cout << "Got ObjectId!" << std::endl;
67-
break;
68-
case type::k_array: {
69-
std::cout << "Got Array!" << std::endl;
70-
// if we have a subarray, we can access it by getting a view of it.
71-
array::view subarr{ele.get_array().value};
72-
for (array::element ele : subarr) {
73-
std::cout << "array element: " << to_json(ele.get_value()) << std::endl;
57+
case type::k_utf8:
58+
std::cout << "Got String!" << std::endl;
59+
break;
60+
case type::k_oid:
61+
std::cout << "Got ObjectId!" << std::endl;
62+
break;
63+
case type::k_array: {
64+
std::cout << "Got Array!" << std::endl;
65+
// if we have a subarray, we can access it by getting a view of it.
66+
array::view subarr{ele.get_array().value};
67+
for (array::element ele : subarr) {
68+
std::cout << "array element: " << to_json(ele.get_value()) << std::endl;
69+
}
70+
break;
7471
}
75-
break;
76-
}
77-
default:
78-
std::cout << "We messed up!" << std::endl;
72+
default:
73+
std::cout << "We messed up!" << std::endl;
7974
}
8075

8176
// usually we don't need to actually use a switch statement, because we can also
8277
// get a variant 'value' that can hold any BSON type.
8378
types::value ele_val{ele.get_value()};
8479
// if we need to print an arbitrary value, we can use to_json, which provides
8580
// a suitable overload.
86-
std::cout << "the value is " << to_json(ele_val) << std::endl;;
81+
std::cout << "the value is " << to_json(ele_val) << std::endl;
82+
;
8783
}
8884

8985
// If we want to search for an element we can use operator[]

examples/mongocxx/bulk_write.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ int main(int, char**) {
9393
}
9494

9595
std::cout << "Upserted IDs" << std::endl;
96-
for (const auto &id : result->upserted_ids()) {
97-
std::cout << "Bulk write index: " << id.first << std::endl << bsoncxx::to_json(id.second) << std::endl;
96+
for (const auto& id : result->upserted_ids()) {
97+
std::cout << "Bulk write index: " << id.first << std::endl
98+
<< bsoncxx::to_json(id.second) << std::endl;
9899
}
99100

100101
// The collection should contain two copies of {"a": 2}.

src/bsoncxx/document/view.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ bson_iter_t to_bson_iter_t(element e) {
3535
i.next_off = e.offset();
3636
return i;
3737
}
38-
} // namespace
38+
} // namespace
3939

4040
view::iterator::iterator() {
4141
}

src/bsoncxx/json.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,10 @@ std::string to_json(types::value value) {
288288

289289
stdx::optional<document::value> from_json(stdx::string_view json) {
290290
bson_error_t error;
291-
bson_t* result = bson_new_from_json(
292-
reinterpret_cast<const uint8_t*>(json.data()), json.size(), &error);
291+
bson_t* result =
292+
bson_new_from_json(reinterpret_cast<const uint8_t*>(json.data()), json.size(), &error);
293293

294-
if (!result)
295-
return stdx::nullopt;
294+
if (!result) return stdx::nullopt;
296295

297296
std::uint32_t length;
298297
std::uint8_t* buf = bson_destroy_with_steal(result, true, &length);

src/bsoncxx/test/bson_get_values.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ TEST_CASE("[] can reach into nested arrays", "[bsoncxx]") {
4949
REQUIRE(!doc["ints"][2][9]);
5050
REQUIRE(!doc["bools"][9]);
5151
}
52-
5352
}
5453

5554
TEST_CASE("[] can reach into nested documents", "[bsoncxx]") {

src/bsoncxx/test/json.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#include <bsoncxx/json.hpp>
55

66
namespace {
7-
constexpr auto k_invalid_json = R"({])";
8-
constexpr auto k_valid_json = R"({ "a" : 1, "b" : 2.0 })";
7+
constexpr auto k_invalid_json = R"({])";
8+
constexpr auto k_valid_json = R"({ "a" : 1, "b" : 2.0 })";
99
}
1010

1111
TEST_CASE("invalid json returns disengaged optional") {
@@ -21,7 +21,8 @@ TEST_CASE("valid json returns an engaged optional") {
2121
TEST_CASE("valid json is converted to equivalent BSON") {
2222
using namespace bsoncxx;
2323

24-
const auto expected = builder::stream::document{} << "a" << 1 << "b" << 2.0 << builder::stream::finalize;
24+
const auto expected = builder::stream::document{} << "a" << 1 << "b" << 2.0
25+
<< builder::stream::finalize;
2526
const auto expected_view = expected.view();
2627

2728
const auto actual = from_json(k_valid_json);

src/bsoncxx/types/value.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ namespace types {
3030
// Boost doesn't mark the copy constructor and copy-assignment operator of string_ref as noexcept
3131
// so we can't rely on automatic noexcept propagation. It really is though, so it is OK.
3232
#if !defined(BSONCXX_POLY_USE_BOOST)
33-
#define BSONCXX_ENUM(name, val) \
34-
value::value(b_##name value) noexcept : _type(static_cast<bsoncxx::type>(val)), \
35-
_b_##name(std::move(value)) { \
36-
static_assert(std::is_nothrow_copy_constructible<b_##name>::value, "Copy may throw"); \
37-
static_assert(std::is_nothrow_copy_assignable<b_##name>::value, "Copy may throw"); \
33+
#define BSONCXX_ENUM(name, val) \
34+
value::value(b_##name value) noexcept : _type(static_cast<bsoncxx::type>(val)), \
35+
_b_##name(std::move(value)) { \
36+
static_assert(std::is_nothrow_copy_constructible<b_##name>::value, "Copy may throw"); \
37+
static_assert(std::is_nothrow_copy_assignable<b_##name>::value, "Copy may throw"); \
3838
static_assert(std::is_nothrow_destructible<b_##name>::value, "Destruction may throw"); \
3939
}
4040
#else
41-
#define BSONCXX_ENUM(name, val) \
42-
value::value(b_##name value) noexcept : _type(static_cast<bsoncxx::type>(val)), \
43-
_b_##name(std::move(value)) { \
41+
#define BSONCXX_ENUM(name, val) \
42+
value::value(b_##name value) noexcept : _type(static_cast<bsoncxx::type>(val)), \
43+
_b_##name(std::move(value)) { \
4444
static_assert(std::is_nothrow_destructible<b_##name>::value, "Destruction may throw"); \
4545
}
4646
#endif

src/mongocxx/exception/operation_exception.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
namespace mongocxx {
2323
MONGOCXX_INLINE_NAMESPACE_BEGIN
2424

25-
operation_exception::operation_exception(std::error_code ec, bsoncxx::document::value&& raw_server_error, std::string what_arg)
25+
operation_exception::operation_exception(std::error_code ec,
26+
bsoncxx::document::value&& raw_server_error,
27+
std::string what_arg)
2628
: exception(ec, what_arg), _raw_server_error{std::move(raw_server_error)} {
2729
}
2830

src/mongocxx/insert_many_builder.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@ options::bulk_write make_bulk_write_options(const options::insert& insert_option
3636
return bw;
3737
}
3838

39-
} // namespace
39+
} // namespace
4040

4141
insert_many_builder::insert_many_builder(const options::insert& options)
42-
: _writes{make_bulk_write_options(options)}, _inserted_ids{}, _index{0} {
43-
};
42+
: _writes{make_bulk_write_options(options)}, _inserted_ids{}, _index{0} {};
4443

4544
void insert_many_builder::operator()(const bsoncxx::document::view& doc) {
4645
if (!doc["_id"]) {

0 commit comments

Comments
 (0)