summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBilly Donahue <billy.donahue@mongodb.com>2019-04-10 12:38:47 -0400
committerBilly Donahue <billy.donahue@mongodb.com>2019-04-11 15:39:51 -0400
commit7f186f909f16e6c3c1365d74ad37603d917d1b85 (patch)
tree0d520fe42983000856800bef0f2aff5c33c9a890 /src
parent32fb818708916a7fea5b0de3028c8fef39396633 (diff)
downloadmongo-7f186f909f16e6c3c1365d74ad37603d917d1b85.tar.gz
SERVER-40389 use fmt in server, add readme file to third_party/fmt
Diffstat (limited to 'src')
-rw-r--r--src/mongo/base/data_type.cpp21
-rw-r--r--src/third_party/fmt/README-mongodb.md4
2 files changed, 17 insertions, 8 deletions
diff --git a/src/mongo/base/data_type.cpp b/src/mongo/base/data_type.cpp
index 6c2d5444b08..879c7175b40 100644
--- a/src/mongo/base/data_type.cpp
+++ b/src/mongo/base/data_type.cpp
@@ -29,22 +29,27 @@
#include "mongo/base/data_type.h"
+#include <fmt/format.h>
+
#include "mongo/util/str.h"
namespace mongo {
+namespace {
+auto makeOverflowStatus(StringData action, size_t sizeOfT, size_t length, size_t debug_offset) {
+ using namespace fmt::literals;
+ return Status(ErrorCodes::Overflow,
+ "buffer size too small to {} ({}) bytes out of buffer[{}] at offset: {}"_format(
+ action, sizeOfT, length, debug_offset));
+}
+} // namespace
+
Status DataType::makeTrivialLoadStatus(size_t sizeOfT, size_t length, size_t debug_offset) {
- str::stream ss;
- ss << "buffer size too small to read (" << sizeOfT << ") bytes out of buffer[" << length
- << "] at offset: " << debug_offset;
- return Status(ErrorCodes::Overflow, ss);
+ return makeOverflowStatus("read", sizeOfT, length, debug_offset);
}
Status DataType::makeTrivialStoreStatus(size_t sizeOfT, size_t length, size_t debug_offset) {
- str::stream ss;
- ss << "buffer size too small to write (" << sizeOfT << ") bytes into buffer[" << length
- << "] at offset: " << debug_offset;
- return Status(ErrorCodes::Overflow, ss);
+ return makeOverflowStatus("write", sizeOfT, length, debug_offset);
}
} // namespace mongo
diff --git a/src/third_party/fmt/README-mongodb.md b/src/third_party/fmt/README-mongodb.md
new file mode 100644
index 00000000000..e87e59eae43
--- /dev/null
+++ b/src/third_party/fmt/README-mongodb.md
@@ -0,0 +1,4 @@
+
+Please read this wiki for notes on using fmt within the mongo project.
+https://wiki.corp.mongodb.com/display/HGTC/Using+the+fmt+Library
+