summaryrefslogtreecommitdiff
path: root/src/mongo/bson
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2016-05-28 17:55:12 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2016-05-28 17:55:12 -0400
commit6dcdd23dd37ef12c87e71cf59ef01cd82432efe0 (patch)
treec8cfb5acb62c80f375bc37e7d4350382deea6a37 /src/mongo/bson
parentd4ac5673ea3f6cef4ce9dbcec90e31813997a528 (diff)
downloadmongo-6dcdd23dd37ef12c87e71cf59ef01cd82432efe0.tar.gz
SERVER-23971 Clang-Format code
Diffstat (limited to 'src/mongo/bson')
-rw-r--r--src/mongo/bson/bson_obj_data_type_test.cpp2
-rw-r--r--src/mongo/bson/bson_obj_test.cpp5
-rw-r--r--src/mongo/bson/bson_validate.cpp2
-rw-r--r--src/mongo/bson/bson_validate_test.cpp30
-rw-r--r--src/mongo/bson/bsonelement.h2
-rw-r--r--src/mongo/bson/bsonobj.cpp2
-rw-r--r--src/mongo/bson/bsonobjbuilder.h2
-rw-r--r--src/mongo/bson/bsonobjbuilder_test.cpp6
-rw-r--r--src/mongo/bson/bsontypes.h2
-rw-r--r--src/mongo/bson/json.cpp6
-rw-r--r--src/mongo/bson/json.h2
-rw-r--r--src/mongo/bson/mutable/algorithm.h2
-rw-r--r--src/mongo/bson/mutable/document.cpp5
-rw-r--r--src/mongo/bson/oid.h2
-rw-r--r--src/mongo/bson/timestamp.cpp2
-rw-r--r--src/mongo/bson/util/bson_check.h5
-rw-r--r--src/mongo/bson/util/bson_check_test.cpp13
-rw-r--r--src/mongo/bson/util/bson_extract.cpp33
-rw-r--r--src/mongo/bson/util/bson_extract_test.cpp6
-rw-r--r--src/mongo/bson/util/builder.h2
20 files changed, 81 insertions, 50 deletions
diff --git a/src/mongo/bson/bson_obj_data_type_test.cpp b/src/mongo/bson/bson_obj_data_type_test.cpp
index cbf5305e45c..21476a7149e 100644
--- a/src/mongo/bson/bson_obj_data_type_test.cpp
+++ b/src/mongo/bson/bson_obj_data_type_test.cpp
@@ -25,8 +25,8 @@
* then also delete it in the license file.
*/
-#include "mongo/base/data_range_cursor.h"
#include "mongo/base/data_range.h"
+#include "mongo/base/data_range_cursor.h"
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonobjbuilder.h"
diff --git a/src/mongo/bson/bson_obj_test.cpp b/src/mongo/bson/bson_obj_test.cpp
index 6cf98fd998b..843dfb13829 100644
--- a/src/mongo/bson/bson_obj_test.cpp
+++ b/src/mongo/bson/bson_obj_test.cpp
@@ -527,7 +527,10 @@ TEST(BSONObj, getFields) {
TEST(BSONObj, getFieldsWithDuplicates) {
auto e = BSON("a" << 2 << "b"
<< "3"
- << "a" << 9 << "b" << 10);
+ << "a"
+ << 9
+ << "b"
+ << 10);
std::array<StringData, 2> fieldNames{"a", "b"};
std::array<BSONElement, 2> fields;
e.getFields(fieldNames, &fields);
diff --git a/src/mongo/bson/bson_validate.cpp b/src/mongo/bson/bson_validate.cpp
index 0f5012d01f3..c578231e435 100644
--- a/src/mongo/bson/bson_validate.cpp
+++ b/src/mongo/bson/bson_validate.cpp
@@ -28,8 +28,8 @@
*/
#include <cstring>
-#include <vector>
#include <limits>
+#include <vector>
#include "mongo/base/data_view.h"
#include "mongo/bson/bson_validate.h"
diff --git a/src/mongo/bson/bson_validate_test.cpp b/src/mongo/bson/bson_validate_test.cpp
index 06a3ee098c3..1d44b237d35 100644
--- a/src/mongo/bson/bson_validate_test.cpp
+++ b/src/mongo/bson/bson_validate_test.cpp
@@ -30,10 +30,10 @@
#include "mongo/platform/basic.h"
#include "mongo/base/data_view.h"
+#include "mongo/bson/bson_validate.h"
#include "mongo/db/jsobj.h"
-#include "mongo/unittest/unittest.h"
#include "mongo/platform/random.h"
-#include "mongo/bson/bson_validate.h"
+#include "mongo/unittest/unittest.h"
#include "mongo/util/log.h"
namespace {
@@ -148,15 +148,23 @@ TEST(BSONValidate, Fuzz) {
log() << "BSONValidate Fuzz random seed: " << seed << endl;
PseudoRandom randomSource(seed);
- BSONObj original =
- BSON("one" << 3 << "two" << 5 << "three" << BSONObj() << "four"
- << BSON("five" << BSON("six" << 11)) << "seven" << BSON_ARRAY("a"
- << "bb"
- << "ccc" << 5)
- << "eight" << BSONDBRef("rrr", OID("01234567890123456789aaaa")) << "_id"
- << OID("deadbeefdeadbeefdeadbeef") << "nine"
- << BSONBinData("\x69\xb7", 2, BinDataGeneral) << "ten"
- << Date_t::fromMillisSinceEpoch(44) << "eleven" << BSONRegEx("foooooo", "i"));
+ BSONObj original = BSON("one" << 3 << "two" << 5 << "three" << BSONObj() << "four"
+ << BSON("five" << BSON("six" << 11))
+ << "seven"
+ << BSON_ARRAY("a"
+ << "bb"
+ << "ccc"
+ << 5)
+ << "eight"
+ << BSONDBRef("rrr", OID("01234567890123456789aaaa"))
+ << "_id"
+ << OID("deadbeefdeadbeefdeadbeef")
+ << "nine"
+ << BSONBinData("\x69\xb7", 2, BinDataGeneral)
+ << "ten"
+ << Date_t::fromMillisSinceEpoch(44)
+ << "eleven"
+ << BSONRegEx("foooooo", "i"));
int32_t fuzzFrequencies[] = {2, 10, 20, 100, 1000};
for (size_t i = 0; i < sizeof(fuzzFrequencies) / sizeof(int32_t); ++i) {
diff --git a/src/mongo/bson/bsonelement.h b/src/mongo/bson/bsonelement.h
index 8798fc58794..876e4a40050 100644
--- a/src/mongo/bson/bsonelement.h
+++ b/src/mongo/bson/bsonelement.h
@@ -37,9 +37,9 @@
#include "mongo/base/data_type_endian.h"
#include "mongo/base/data_view.h"
+#include "mongo/base/string_data_comparator_interface.h"
#include "mongo/bson/bsontypes.h"
#include "mongo/bson/oid.h"
-#include "mongo/base/string_data_comparator_interface.h"
#include "mongo/bson/timestamp.h"
#include "mongo/config.h"
#include "mongo/platform/decimal128.h"
diff --git a/src/mongo/bson/bsonobj.cpp b/src/mongo/bson/bsonobj.cpp
index 5c19d28a3c3..8a492643608 100644
--- a/src/mongo/bson/bsonobj.cpp
+++ b/src/mongo/bson/bsonobj.cpp
@@ -844,7 +844,7 @@ bool BSONIteratorSorted::ElementFieldCmp::operator()(const char* s1, const char*
}
BSONIteratorSorted::BSONIteratorSorted(const BSONObj& o, const ElementFieldCmp& cmp)
- : _nfields(o.nFields()), _fields(new const char* [_nfields]) {
+ : _nfields(o.nFields()), _fields(new const char*[_nfields]) {
int x = 0;
BSONObjIterator i(o);
while (i.more()) {
diff --git a/src/mongo/bson/bsonobjbuilder.h b/src/mongo/bson/bsonobjbuilder.h
index a3bf857095f..3a3f91a60cf 100644
--- a/src/mongo/bson/bsonobjbuilder.h
+++ b/src/mongo/bson/bsonobjbuilder.h
@@ -34,9 +34,9 @@
#pragma once
-#include <map>
#include <cmath>
#include <limits>
+#include <map>
#include "mongo/base/data_view.h"
#include "mongo/base/parse_number.h"
diff --git a/src/mongo/bson/bsonobjbuilder_test.cpp b/src/mongo/bson/bsonobjbuilder_test.cpp
index fdee41b8ba1..f9bad62059f 100644
--- a/src/mongo/bson/bsonobjbuilder_test.cpp
+++ b/src/mongo/bson/bsonobjbuilder_test.cpp
@@ -33,8 +33,8 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/json.h"
-#include <sstream>
#include "mongo/unittest/unittest.h"
+#include <sstream>
namespace {
@@ -300,7 +300,9 @@ TEST(BSONObjBuilderTest, ResumeBuildingWithNesting) {
auto obj = BSONObj(b.buf());
ASSERT_EQ(obj,
BSON("ll" << BSON("f" << BSON("cc"
- << "dd")) << "a" << BSON("c" << 3)));
+ << "dd"))
+ << "a"
+ << BSON("c" << 3)));
}
TEST(BSONObjBuilderTest, ResetToEmptyResultsInEmptyObj) {
diff --git a/src/mongo/bson/bsontypes.h b/src/mongo/bson/bsontypes.h
index fa21b9e5020..1685249e9ef 100644
--- a/src/mongo/bson/bsontypes.h
+++ b/src/mongo/bson/bsontypes.h
@@ -29,9 +29,9 @@
#pragma once
+#include "mongo/config.h"
#include "mongo/platform/decimal128.h"
#include "mongo/util/assert_util.h"
-#include "mongo/config.h"
namespace mongo {
diff --git a/src/mongo/bson/json.cpp b/src/mongo/bson/json.cpp
index 796771b41aa..fffbd042328 100644
--- a/src/mongo/bson/json.cpp
+++ b/src/mongo/bson/json.cpp
@@ -76,9 +76,9 @@ enum {
DATE_RESERVE_SIZE = 64
};
-static const char* LBRACE = "{", * RBRACE = "}", * LBRACKET = "[", * RBRACKET = "]", * LPAREN = "(",
- * RPAREN = ")", * COLON = ":", * COMMA = ",", * FORWARDSLASH = "/",
- * SINGLEQUOTE = "'", * DOUBLEQUOTE = "\"";
+static const char *LBRACE = "{", *RBRACE = "}", *LBRACKET = "[", *RBRACKET = "]", *LPAREN = "(",
+ *RPAREN = ")", *COLON = ":", *COMMA = ",", *FORWARDSLASH = "/",
+ *SINGLEQUOTE = "'", *DOUBLEQUOTE = "\"";
JParse::JParse(StringData str)
: _buf(str.rawData()), _input(_buf), _input_end(_input + str.size()) {}
diff --git a/src/mongo/bson/json.h b/src/mongo/bson/json.h
index 8553f79408e..5e5516607a1 100644
--- a/src/mongo/bson/json.h
+++ b/src/mongo/bson/json.h
@@ -30,8 +30,8 @@
#include <string>
-#include "mongo/bson/bsonobj.h"
#include "mongo/base/status.h"
+#include "mongo/bson/bsonobj.h"
namespace mongo {
diff --git a/src/mongo/bson/mutable/algorithm.h b/src/mongo/bson/mutable/algorithm.h
index 66cec29956a..850f37d9f00 100644
--- a/src/mongo/bson/mutable/algorithm.h
+++ b/src/mongo/bson/mutable/algorithm.h
@@ -27,8 +27,8 @@
#pragma once
-#include <cstddef>
#include <algorithm>
+#include <cstddef>
#include <vector>
#include "mongo/bson/mutable/const_element.h"
diff --git a/src/mongo/bson/mutable/document.cpp b/src/mongo/bson/mutable/document.cpp
index 2afe8c8de96..5ae92341217 100644
--- a/src/mongo/bson/mutable/document.cpp
+++ b/src/mongo/bson/mutable/document.cpp
@@ -777,8 +777,9 @@ public:
// It should be impossible to have an opaque left child and be non-serialized,
dassert(rep->serialized);
- BSONElement childElt = (hasValue(*rep) ? getSerializedElement(*rep).embeddedObject()
- : getObject(rep->objIdx)).firstElement();
+ BSONElement childElt =
+ (hasValue(*rep) ? getSerializedElement(*rep).embeddedObject() : getObject(rep->objIdx))
+ .firstElement();
if (!childElt.eoo()) {
// Do this now before other writes so compiler can exploit knowing
diff --git a/src/mongo/bson/oid.h b/src/mongo/bson/oid.h
index 0cc1e2629e3..7debe105409 100644
--- a/src/mongo/bson/oid.h
+++ b/src/mongo/bson/oid.h
@@ -89,7 +89,7 @@ public:
}
/** init from a reference to a 12-byte array */
- explicit OID(const unsigned char(&arr)[kOIDSize]) {
+ explicit OID(const unsigned char (&arr)[kOIDSize]) {
std::memcpy(_data, arr, sizeof(arr));
}
diff --git a/src/mongo/bson/timestamp.cpp b/src/mongo/bson/timestamp.cpp
index 2abd3a8990a..45230597ddf 100644
--- a/src/mongo/bson/timestamp.cpp
+++ b/src/mongo/bson/timestamp.cpp
@@ -25,8 +25,8 @@
* then also delete it in the license file.
*/
-#include "mongo/bson/bsontypes.h"
#include "mongo/bson/timestamp.h"
+#include "mongo/bson/bsontypes.h"
#include <cstdint>
#include <ctime>
diff --git a/src/mongo/bson/util/bson_check.h b/src/mongo/bson/util/bson_check.h
index 4f2585e9e75..dd4f59816ba 100644
--- a/src/mongo/bson/util/bson_check.h
+++ b/src/mongo/bson/util/bson_check.h
@@ -64,7 +64,8 @@ Status bsonCheckOnlyHasFields(StringData objectName,
if (occurrences[i] > 1) {
return Status(ErrorCodes::DuplicateKey,
str::stream() << "Field " << *curr << " appears " << occurrences[i]
- << " times in " << objectName);
+ << " times in "
+ << objectName);
}
}
return Status::OK();
@@ -77,7 +78,7 @@ Status bsonCheckOnlyHasFields(StringData objectName,
template <typename StringType, int N>
Status bsonCheckOnlyHasFields(StringData objectName,
const BSONObj& o,
- const StringType(&legals)[N]) {
+ const StringType (&legals)[N]) {
return bsonCheckOnlyHasFields(objectName, o, &legals[0], legals + N);
}
diff --git a/src/mongo/bson/util/bson_check_test.cpp b/src/mongo/bson/util/bson_check_test.cpp
index f14da7fa459..18365f9ee62 100644
--- a/src/mongo/bson/util/bson_check_test.cpp
+++ b/src/mongo/bson/util/bson_check_test.cpp
@@ -49,19 +49,26 @@ TEST(BsonCheck, CheckHasOnlyLegalFields) {
ASSERT_OK(bsonCheckOnlyHasFields("",
BSON("aField"
<< "value"
- << "thirdField" << 1 << "anotherField" << 2),
+ << "thirdField"
+ << 1
+ << "anotherField"
+ << 2),
legals));
ASSERT_OK(bsonCheckOnlyHasFields("",
BSON("aField"
<< "value"
- << "thirdField" << 1),
+ << "thirdField"
+ << 1),
legals));
ASSERT_EQUALS(ErrorCodes::BadValue,
bsonCheckOnlyHasFields("",
BSON("aField"
<< "value"
- << "illegal" << 4 << "thirdField" << 1),
+ << "illegal"
+ << 4
+ << "thirdField"
+ << 1),
legals));
}
diff --git a/src/mongo/bson/util/bson_extract.cpp b/src/mongo/bson/util/bson_extract.cpp
index 095185e4baa..b3ff37ca1b2 100644
--- a/src/mongo/bson/util/bson_extract.cpp
+++ b/src/mongo/bson/util/bson_extract.cpp
@@ -37,7 +37,8 @@ Status bsonExtractField(const BSONObj& object, StringData fieldName, BSONElement
if (element.eoo())
return Status(ErrorCodes::NoSuchKey,
mongoutils::str::stream() << "Missing expected field \""
- << fieldName.toString() << "\"");
+ << fieldName.toString()
+ << "\"");
*outElement = element;
return Status::OK();
}
@@ -51,9 +52,11 @@ Status bsonExtractTypedField(const BSONObj& object,
return status;
if (type != outElement->type()) {
return Status(ErrorCodes::TypeMismatch,
- mongoutils::str::stream()
- << "\"" << fieldName << "\" had the wrong type. Expected "
- << typeName(type) << ", found " << typeName(outElement->type()));
+ mongoutils::str::stream() << "\"" << fieldName
+ << "\" had the wrong type. Expected "
+ << typeName(type)
+ << ", found "
+ << typeName(outElement->type()));
}
return Status::OK();
}
@@ -81,7 +84,8 @@ Status bsonExtractBooleanFieldWithDefault(const BSONObj& object,
} else if (!value.isNumber() && !value.isBoolean()) {
return Status(ErrorCodes::TypeMismatch,
mongoutils::str::stream() << "Expected boolean or number type for field \""
- << fieldName << "\", found "
+ << fieldName
+ << "\", found "
<< typeName(value.type()));
} else {
*out = value.trueValue();
@@ -155,11 +159,12 @@ Status bsonExtractIntegerField(const BSONObj& object, StringData fieldName, long
}
long long result = value.safeNumberLong();
if (result != value.numberDouble()) {
- return Status(ErrorCodes::BadValue,
- mongoutils::str::stream()
- << "Expected field \"" << fieldName
- << "\" to have a value "
- "exactly representable as a 64-bit integer, but found " << value);
+ return Status(
+ ErrorCodes::BadValue,
+ mongoutils::str::stream() << "Expected field \"" << fieldName
+ << "\" to have a value "
+ "exactly representable as a 64-bit integer, but found "
+ << value);
}
*out = result;
return Status::OK();
@@ -188,9 +193,11 @@ Status bsonExtractIntegerFieldWithDefaultIf(const BSONObj& object,
return status;
}
if (!pred(*out)) {
- return Status(ErrorCodes::BadValue,
- mongoutils::str::stream() << "Invalid value in field \"" << fieldName
- << "\": " << *out << ": " << predDescription);
+ return Status(
+ ErrorCodes::BadValue,
+ mongoutils::str::stream() << "Invalid value in field \"" << fieldName << "\": " << *out
+ << ": "
+ << predDescription);
}
return Status::OK();
}
diff --git a/src/mongo/bson/util/bson_extract_test.cpp b/src/mongo/bson/util/bson_extract_test.cpp
index 8ec13d1fbd1..9ef6a448e80 100644
--- a/src/mongo/bson/util/bson_extract_test.cpp
+++ b/src/mongo/bson/util/bson_extract_test.cpp
@@ -89,10 +89,12 @@ TEST(ExtractBSON, ExtractStringFieldWithDefault) {
TEST(ExtractBSON, ExtractBooleanFieldWithDefault) {
BSONObj obj1 = BSON("a" << 1 << "b"
<< "hello"
- << "c" << true);
+ << "c"
+ << true);
BSONObj obj2 = BSON("a" << 0 << "b"
<< "hello"
- << "c" << false);
+ << "c"
+ << false);
bool b;
b = false;
ASSERT_OK(bsonExtractBooleanFieldWithDefault(obj1, "a", false, &b));
diff --git a/src/mongo/bson/util/builder.h b/src/mongo/bson/util/builder.h
index 1b43a69ad27..f440e9b8fcb 100644
--- a/src/mongo/bson/util/builder.h
+++ b/src/mongo/bson/util/builder.h
@@ -32,8 +32,8 @@
#include <cfloat>
#include <sstream>
#include <stdio.h>
-#include <string>
#include <string.h>
+#include <string>
#include "mongo/base/data_type_endian.h"