diff options
Diffstat (limited to 'src/mongo/bson/util/builder.h')
-rw-r--r-- | src/mongo/bson/util/builder.h | 9 |
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; |