diff options
Diffstat (limited to 'src/mongo/bson')
-rw-r--r-- | src/mongo/bson/util/builder.h | 10 | ||||
-rw-r--r-- | src/mongo/bson/util/builder_fwd.h | 51 |
2 files changed, 53 insertions, 8 deletions
diff --git a/src/mongo/bson/util/builder.h b/src/mongo/bson/util/builder.h index 70daf863547..3ddb5b561fb 100644 --- a/src/mongo/bson/util/builder.h +++ b/src/mongo/bson/util/builder.h @@ -40,6 +40,8 @@ #include <boost/optional.hpp> +#include "mongo/bson/util/builder_fwd.h" + #include "mongo/base/data_type_endian.h" #include "mongo/base/data_view.h" #include "mongo/base/static_assert.h" @@ -73,9 +75,6 @@ const int BSONObjMaxInternalSize = BSONObjMaxUserSize + (16 * 1024); const int BufferMaxSize = 64 * 1024 * 1024; -template <typename Builder> -class StringBuilderImpl; - class SharedBufferAllocator { SharedBufferAllocator(const SharedBufferAllocator&) = delete; SharedBufferAllocator& operator=(const SharedBufferAllocator&) = delete; @@ -220,7 +219,6 @@ private: UniqueBuffer _buf; }; -enum { StackSizeDefault = 512 }; template <size_t SZ> class StackAllocator { StackAllocator(const StackAllocator&) = delete; @@ -527,7 +525,6 @@ public: StackBufBuilderBase(const StackBufBuilderBase&) = delete; StackBufBuilderBase(StackBufBuilderBase&&) = delete; }; -using StackBufBuilder = StackBufBuilderBase<StackSizeDefault>; MONGO_STATIC_ASSERT(!std::is_move_constructible<StackBufBuilder>::value); /** std::stringstream deals with locale so this is a lot faster than std::stringstream for UTF8 */ @@ -695,9 +692,6 @@ private: Builder _buf; }; -using StringBuilder = StringBuilderImpl<BufBuilder>; -using StackStringBuilder = StringBuilderImpl<StackBufBuilderBase<StackSizeDefault>>; - extern template class StringBuilderImpl<BufBuilder>; extern template class StringBuilderImpl<StackBufBuilderBase<StackSizeDefault>>; diff --git a/src/mongo/bson/util/builder_fwd.h b/src/mongo/bson/util/builder_fwd.h new file mode 100644 index 00000000000..b855511ed49 --- /dev/null +++ b/src/mongo/bson/util/builder_fwd.h @@ -0,0 +1,51 @@ +/** + * Copyright (C) 2018-present MongoDB, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the Server Side Public License, version 1, + * as published by MongoDB, Inc. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Server Side Public License for more details. + * + * You should have received a copy of the Server Side Public License + * along with this program. If not, see + * <http://www.mongodb.com/licensing/server-side-public-license>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the Server Side Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#pragma once + +#include <cstddef> + +namespace mongo { + +class BufBuilder; + +template <std::size_t SZ> +class StackBufBuilderBase; + +inline constexpr std::size_t StackSizeDefault = 512; + +using StackBufBuilder = StackBufBuilderBase<StackSizeDefault>; + +template <typename Allocator> +class StringBuilderImpl; + +using StringBuilder = StringBuilderImpl<BufBuilder>; +using StackStringBuilder = StringBuilderImpl<StackBufBuilder>; + +} // namespace mongo |