summaryrefslogtreecommitdiff
path: root/src/mongo/bson/util/builder.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/bson/util/builder.h')
-rw-r--r--src/mongo/bson/util/builder.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mongo/bson/util/builder.h b/src/mongo/bson/util/builder.h
index e6d29ceb175..258e63cf52d 100644
--- a/src/mongo/bson/util/builder.h
+++ b/src/mongo/bson/util/builder.h
@@ -446,6 +446,15 @@ public:
return std::string(_buf.buf(), _buf.l);
}
+ /**
+ * Returns a view of this string without copying.
+ *
+ * WARNING: the view expires when this StringBuilder is modified or destroyed.
+ */
+ StringData stringData() const {
+ return StringData(_buf.buf(), _buf.l);
+ }
+
/** size of current std::string */
int len() const {
return _buf.l;