Skip to content

CXX-2288 Add forward headers for bsoncxx and mongocxx #1061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 68 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
6269f15
Add forwarding headers to clang-format rules
eramongodb Nov 10, 2023
b8b6e73
Add forward header for bsoncxx/types.hpp
eramongodb Nov 10, 2023
f95e7b1
Add forward header for bsoncxx/types/bson_value/value.hpp
eramongodb Nov 10, 2023
d1a81d4
Add forward header for bsoncxx/types/bson_value/view.hpp
eramongodb Nov 10, 2023
3fa234d
Add forward header for bsoncxx/array/element.hpp
eramongodb Nov 10, 2023
cd9e7d0
Add forward header for bsoncxx/document/element.hpp
eramongodb Nov 10, 2023
029141b
Add forward header for bsoncxx/builder/basic/array.hpp
eramongodb Nov 10, 2023
3c56264
Make using namespace declaration in list.hpp VERY noticable
eramongodb Nov 10, 2023
82ec185
Remove redundant redeclaration with BSONCXX_API
eramongodb Nov 10, 2023
011c563
Avoid confusion between bsoncxx::builder::document and bsoncxx::document
eramongodb Nov 10, 2023
d581328
Avoid confusion between bson_value::view and bson_value::value::view
eramongodb Nov 10, 2023
9d85948
Add forward header for bsoncxx/builder/list.hpp
eramongodb Nov 10, 2023
e231a0a
Add forward header for bsoncxx/validate.hpp
eramongodb Nov 10, 2023
819f0cb
Add forward header for bsoncxx/array/view.hpp
eramongodb Nov 10, 2023
65a2b14
Add forward header for bsoncxx/builder/core.hpp
eramongodb Nov 10, 2023
83ba1b1
Add forward header for bsoncxx/builder/stream/closed_context.hpp
eramongodb Nov 10, 2023
7a876e0
Add forward header for bsoncxx/builder/stream/key_context.hpp
eramongodb Nov 10, 2023
396283c
Add forward header for bsoncxx/builder/stream/single_context.hpp
eramongodb Nov 10, 2023
219bed7
Add forward header for bsoncxx/document/view.hpp
eramongodb Nov 10, 2023
e3f44ab
Add forward header for remaining bsoncxx headers
eramongodb Nov 10, 2023
da76328
Add bsoncxx/fwd.hpp
eramongodb Nov 10, 2023
341c738
Remove unnecessary forward declaration of mongocxx::client
eramongodb Nov 10, 2023
5734e13
Remove redundant redeclaration with MONGOCXX_API
eramongodb Nov 10, 2023
1c46796
Avoid confusion between gridfs::bucket and options::gridfs::bucket
eramongodb Nov 10, 2023
cfff83c
Avoid confusion between mongocxx::client and mongocxx::options::client
eramongodb Nov 10, 2023
19329b7
Avoid confusion between mongocxx::pool and mongocxx::options::pool
eramongodb Nov 10, 2023
a769d1c
Qualify friend declarations for test_util classes
eramongodb Nov 10, 2023
eed3762
Add forward header for mongocxx/client.hpp
eramongodb Nov 10, 2023
54d3869
Add forward header for mongocxx/collection.hpp
eramongodb Nov 10, 2023
16b8da2
Add forward header for mongocxx/database.hpp
eramongodb Nov 10, 2023
2c6f2bc
Add forward header for mongocxx/client_session.hpp
eramongodb Nov 10, 2023
c6ae3f8
Add forward header for mongocxx/uri.hpp
eramongodb Nov 10, 2023
f161604
Add forward header for mongocxx/client_encryption.hpp
eramongodb Nov 10, 2023
937ff58
Add forward header for mongocxx/bulk_write.hpp
eramongodb Nov 10, 2023
12bd6ed
Add forward header for mongocxx/search_index_view.hpp
eramongodb Nov 10, 2023
66b8c3c
Add forward header for mongocxx/logger.hpp
eramongodb Nov 10, 2023
30ec326
Add forward header for mongocxx/pool.hpp
eramongodb Nov 10, 2023
bfd8739
Add forward header for mongocxx/read_concern.hpp
eramongodb Nov 10, 2023
f66f5ee
Add forward header for mongocxx/write_concern.hpp
eramongodb Nov 10, 2023
1fe4381
Add forward header for mongocxx/read_preference.hpp
eramongodb Nov 10, 2023
1a0c730
Add forward header for mongocxx/events/topology_description.hpp
eramongodb Nov 10, 2023
e0c625c
Add forward header for mongocxx/options/transaction.hpp
eramongodb Nov 10, 2023
e0de6c1
Add forward header for mongocxx/index_view.hpp
eramongodb Nov 10, 2023
fb51e76
Add forward header for mongocxx/gridfs/bucket.hpp
eramongodb Nov 10, 2023
b249f2a
Add forward header for mongocxx/options/auto_encryption.hpp
eramongodb Nov 10, 2023
88763a7
Add forward header for mongocxx/options/client_encryption.hpp
eramongodb Nov 10, 2023
c3ab0fa
Add forward header for remaining mongocxx headers
eramongodb Nov 10, 2023
d1f5085
Add mongocxx/fwd.hpp
eramongodb Nov 10, 2023
f4b10cd
Use simple-type-specifier form for friend class declarations
eramongodb Nov 10, 2023
9e3f0fd
Workaround MSVC 2015 warning C2875 for mock.hh friend declarations
eramongodb Nov 10, 2023
328fe69
Avoid redeclarations of bsoncxx::oid
eramongodb Nov 16, 2023
89528fa
Avoid redeclarations of bsoncxx::types::bson_value::value
eramongodb Nov 16, 2023
60155a5
Avoid redeclarations of mongocxx::bulk_write
eramongodb Nov 16, 2023
002b4f7
Avoid redeclarations of mongocxx::change_stream
eramongodb Nov 16, 2023
22b828e
Avoid redeclarations of mongocxx::client
eramongodb Nov 16, 2023
483dfc7
Avoid redeclarations of mongocxx::client_encryption
eramongodb Nov 16, 2023
ae2dd1f
Avoid redeclarations of mongocxx::collection
eramongodb Nov 16, 2023
6b91337
Avoid redeclarations of mongocxx::database
eramongodb Nov 16, 2023
8d3bd55
Avoid redeclarations of mongocxx::gridfs::bucket
eramongodb Nov 16, 2023
c3d2a5e
Avoid redeclarations of mongocxx::hint
eramongodb Nov 16, 2023
469e6bb
Avoid redeclarations of mongocxx::index_view
eramongodb Nov 16, 2023
5b5edb0
Avoid redeclarations of mongocxx::read_concern
eramongodb Nov 16, 2023
28ea252
Avoid redeclarations of mongocxx::read_preference
eramongodb Nov 16, 2023
fe9fa62
Avoid redeclarations of mongocxx::search_index_view
eramongodb Nov 16, 2023
90dffdd
Avoid redeclarations of mongocxx::uri
eramongodb Nov 16, 2023
e6f2580
Avoid redeclarations of mongocxx::validation_criteria
eramongodb Nov 16, 2023
16956c9
Avoid redeclarations of mongocxx::write_concern
eramongodb Nov 16, 2023
c4dda72
Merge remote-tracking branch 'upstream/master' into cxx-2288
eramongodb Dec 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 6 additions & 4 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ Cpp11BracedListStyle: true
DerivePointerAlignment: false
IncludeBlocks: Regroup
IncludeCategories:
- Regex: 'prelude\.(hpp|hh)' # preludes
Priority: 3
- Regex: '<[[:alnum:]_.]+>' # system headers
- Regex: 'prelude\.(hpp|hh)' # preludes
Priority: 4
- Regex: '<[[:alnum:]_.]+>' # system headers
Priority: 1
- Regex: '.*' # driver headers
- Regex: '.*(-|\/)fwd\.(hpp|hh)' # forwarding headers
Priority: 2
- Regex: '.*' # driver headers
Priority: 3
IndentWidth: 4
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
Expand Down
32 changes: 32 additions & 0 deletions src/bsoncxx/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,55 +20,87 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/

set_dist_list(src_bsoncxx_include_DIST
CMakeLists.txt
bsoncxx/v_noabi/bsoncxx/array/element-fwd.hpp
bsoncxx/v_noabi/bsoncxx/array/element.hpp
bsoncxx/v_noabi/bsoncxx/array/value-fwd.hpp
bsoncxx/v_noabi/bsoncxx/array/value.hpp
bsoncxx/v_noabi/bsoncxx/array/view_or_value.hpp
bsoncxx/v_noabi/bsoncxx/array/view-fwd.hpp
bsoncxx/v_noabi/bsoncxx/array/view.hpp
bsoncxx/v_noabi/bsoncxx/builder/basic/array-fwd.hpp
bsoncxx/v_noabi/bsoncxx/builder/basic/array.hpp
bsoncxx/v_noabi/bsoncxx/builder/basic/document-fwd.hpp
bsoncxx/v_noabi/bsoncxx/builder/basic/document.hpp
bsoncxx/v_noabi/bsoncxx/builder/basic/helpers.hpp
bsoncxx/v_noabi/bsoncxx/builder/basic/impl.hpp
bsoncxx/v_noabi/bsoncxx/builder/basic/kvp.hpp
bsoncxx/v_noabi/bsoncxx/builder/basic/sub_array-fwd.hpp
bsoncxx/v_noabi/bsoncxx/builder/basic/sub_array.hpp
bsoncxx/v_noabi/bsoncxx/builder/basic/sub_document-fwd.hpp
bsoncxx/v_noabi/bsoncxx/builder/basic/sub_document.hpp
bsoncxx/v_noabi/bsoncxx/builder/concatenate-fwd.hpp
bsoncxx/v_noabi/bsoncxx/builder/concatenate.hpp
bsoncxx/v_noabi/bsoncxx/builder/core-fwd.hpp
bsoncxx/v_noabi/bsoncxx/builder/core.hpp
bsoncxx/v_noabi/bsoncxx/builder/list-fwd.hpp
bsoncxx/v_noabi/bsoncxx/builder/list.hpp
bsoncxx/v_noabi/bsoncxx/builder/stream/array_context-fwd.hpp
bsoncxx/v_noabi/bsoncxx/builder/stream/array_context.hpp
bsoncxx/v_noabi/bsoncxx/builder/stream/array-fwd.hpp
bsoncxx/v_noabi/bsoncxx/builder/stream/array.hpp
bsoncxx/v_noabi/bsoncxx/builder/stream/closed_context-fwd.hpp
bsoncxx/v_noabi/bsoncxx/builder/stream/closed_context.hpp
bsoncxx/v_noabi/bsoncxx/builder/stream/document-fwd.hpp
bsoncxx/v_noabi/bsoncxx/builder/stream/document.hpp
bsoncxx/v_noabi/bsoncxx/builder/stream/helpers-fwd.hpp
bsoncxx/v_noabi/bsoncxx/builder/stream/helpers.hpp
bsoncxx/v_noabi/bsoncxx/builder/stream/key_context-fwd.hpp
bsoncxx/v_noabi/bsoncxx/builder/stream/key_context.hpp
bsoncxx/v_noabi/bsoncxx/builder/stream/single_context-fwd.hpp
bsoncxx/v_noabi/bsoncxx/builder/stream/single_context.hpp
bsoncxx/v_noabi/bsoncxx/builder/stream/value_context-fwd.hpp
bsoncxx/v_noabi/bsoncxx/builder/stream/value_context.hpp
bsoncxx/v_noabi/bsoncxx/config/compiler.hpp
bsoncxx/v_noabi/bsoncxx/config/postlude.hpp
bsoncxx/v_noabi/bsoncxx/config/prelude.hpp
bsoncxx/v_noabi/bsoncxx/decimal128-fwd.hpp
bsoncxx/v_noabi/bsoncxx/decimal128.hpp
bsoncxx/v_noabi/bsoncxx/document/element-fwd.hpp
bsoncxx/v_noabi/bsoncxx/document/element.hpp
bsoncxx/v_noabi/bsoncxx/document/value-fwd.hpp
bsoncxx/v_noabi/bsoncxx/document/value.hpp
bsoncxx/v_noabi/bsoncxx/document/view_or_value.hpp
bsoncxx/v_noabi/bsoncxx/document/view-fwd.hpp
bsoncxx/v_noabi/bsoncxx/document/view.hpp
bsoncxx/v_noabi/bsoncxx/enums/binary_sub_type.hpp
bsoncxx/v_noabi/bsoncxx/enums/type.hpp
bsoncxx/v_noabi/bsoncxx/exception/error_code-fwd.hpp
bsoncxx/v_noabi/bsoncxx/exception/error_code.hpp
bsoncxx/v_noabi/bsoncxx/exception/exception-fwd.hpp
bsoncxx/v_noabi/bsoncxx/exception/exception.hpp
bsoncxx/v_noabi/bsoncxx/json-fwd.hpp
bsoncxx/v_noabi/bsoncxx/json.hpp
bsoncxx/v_noabi/bsoncxx/oid-fwd.hpp
bsoncxx/v_noabi/bsoncxx/oid.hpp
bsoncxx/v_noabi/bsoncxx/stdx/make_unique.hpp
bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp
bsoncxx/v_noabi/bsoncxx/stdx/string_view.hpp
bsoncxx/v_noabi/bsoncxx/stdx/type_traits.hpp
bsoncxx/v_noabi/bsoncxx/string/to_string.hpp
bsoncxx/v_noabi/bsoncxx/string/view_or_value-fwd.hpp
bsoncxx/v_noabi/bsoncxx/string/view_or_value.hpp
bsoncxx/v_noabi/bsoncxx/types-fwd.hpp
bsoncxx/v_noabi/bsoncxx/types.hpp
bsoncxx/v_noabi/bsoncxx/types/bson_value/make_value.hpp
bsoncxx/v_noabi/bsoncxx/types/bson_value/value-fwd.hpp
bsoncxx/v_noabi/bsoncxx/types/bson_value/value.hpp
bsoncxx/v_noabi/bsoncxx/types/bson_value/view_or_value.hpp
bsoncxx/v_noabi/bsoncxx/types/bson_value/view-fwd.hpp
bsoncxx/v_noabi/bsoncxx/types/bson_value/view.hpp
bsoncxx/v_noabi/bsoncxx/types/value.hpp
bsoncxx/v_noabi/bsoncxx/util/functor.hpp
bsoncxx/v_noabi/bsoncxx/validate-fwd.hpp
bsoncxx/v_noabi/bsoncxx/validate.hpp
bsoncxx/v_noabi/bsoncxx/view_or_value-fwd.hpp
bsoncxx/v_noabi/bsoncxx/view_or_value.hpp
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2023 MongoDB Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <bsoncxx/config/prelude.hpp>

namespace bsoncxx {
inline namespace v_noabi {
namespace array {

class BSONCXX_API element;

} // namespace array
} // namespace v_noabi
} // namespace bsoncxx

#include <bsoncxx/config/postlude.hpp>
15 changes: 6 additions & 9 deletions src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@
#include <cstddef>
#include <cstdint>

#include <bsoncxx/array/element-fwd.hpp>
#include <bsoncxx/array/view-fwd.hpp>
#include <bsoncxx/types/bson_value/view-fwd.hpp>

#include <bsoncxx/document/element.hpp>

#include <bsoncxx/config/prelude.hpp>

namespace bsoncxx {
inline namespace v_noabi {
namespace types {
namespace bson_value {
class view;
} // namespace bson_value
} // namespace types

namespace array {

///
Expand All @@ -38,7 +36,7 @@ namespace array {
/// interrogated by calling type() and a specific value can be extracted through
/// get_X() accessors.
///
class BSONCXX_API element : private document::element {
class element : private document::element {
public:
element();

Expand Down Expand Up @@ -80,7 +78,7 @@ class BSONCXX_API element : private document::element {
using document::element::raw;

private:
friend class view;
friend ::bsoncxx::v_noabi::array::view;

BSONCXX_PRIVATE explicit element(const std::uint8_t* raw,
std::uint32_t length,
Expand Down Expand Up @@ -121,7 +119,6 @@ BSONCXX_API bool BSONCXX_CALL operator!=(const types::bson_value::view& v, const
///

} // namespace array

} // namespace v_noabi
} // namespace bsoncxx

Expand Down
29 changes: 29 additions & 0 deletions src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/value-fwd.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2023 MongoDB Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <bsoncxx/config/prelude.hpp>

namespace bsoncxx {
inline namespace v_noabi {
namespace array {

class BSONCXX_API value;

} // namespace array
} // namespace v_noabi
} // namespace bsoncxx

#include <bsoncxx/config/postlude.hpp>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <cstdlib>
#include <memory>

#include <bsoncxx/array/value-fwd.hpp>

#include <bsoncxx/array/view.hpp>
#include <bsoncxx/document/value.hpp>

Expand All @@ -31,7 +33,7 @@ namespace array {
/// out of scope, the underlying buffer is freed. Generally this class should be used
/// sparingly; array::view should be used instead wherever possible.
///
class BSONCXX_API value {
class value {
public:
using deleter_type = void (*)(std::uint8_t*);
using unique_ptr_type = std::unique_ptr<uint8_t[], deleter_type>;
Expand Down
29 changes: 29 additions & 0 deletions src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/view-fwd.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2023 MongoDB Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <bsoncxx/config/prelude.hpp>

namespace bsoncxx {
inline namespace v_noabi {
namespace array {

class BSONCXX_API view;

} // namespace array
} // namespace v_noabi
} // namespace bsoncxx

#include <bsoncxx/config/postlude.hpp>
13 changes: 5 additions & 8 deletions src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,22 @@
#include <cstdint>
#include <iterator>

#include <bsoncxx/array/view-fwd.hpp>
#include <bsoncxx/types/bson_value/view-fwd.hpp>

#include <bsoncxx/array/element.hpp>
#include <bsoncxx/document/view.hpp>

#include <bsoncxx/config/prelude.hpp>

namespace bsoncxx {
inline namespace v_noabi {
namespace types {
namespace bson_value {
class view;
} // namespace bson_value
} // namespace types

namespace array {

///
/// A read-only, non-owning view of a BSON document.
///
class BSONCXX_API view {
class view {
public:
class BSONCXX_API const_iterator;
using iterator = const_iterator;
Expand Down Expand Up @@ -155,7 +152,7 @@ class BSONCXX_API view {
/// This iterator type provides a const forward iterator interface to array
/// view elements.
///
class BSONCXX_API view::const_iterator {
class view::const_iterator {
public:
///
/// std::iterator_traits
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2023 MongoDB Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

namespace bsoncxx {
inline namespace v_noabi {
namespace builder {
namespace basic {

class array;

} // namespace basic
} // namespace builder
} // namespace v_noabi
} // namespace bsoncxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#pragma once

#include <bsoncxx/builder/basic/array-fwd.hpp>

#include <bsoncxx/array/value.hpp>
#include <bsoncxx/array/view.hpp>
#include <bsoncxx/builder/basic/impl.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2023 MongoDB Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

namespace bsoncxx {
inline namespace v_noabi {
namespace builder {
namespace basic {

class document;

} // namespace basic
} // namespace builder
} // namespace v_noabi
} // namespace bsoncxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

#pragma once

#include <bsoncxx/builder/basic/array-fwd.hpp>
#include <bsoncxx/builder/basic/document-fwd.hpp>

#include <bsoncxx/builder/basic/impl.hpp>
#include <bsoncxx/builder/basic/kvp.hpp>
#include <bsoncxx/builder/basic/sub_document.hpp>
Expand All @@ -28,8 +31,6 @@ inline namespace v_noabi {
namespace builder {
namespace basic {

class array;

///
/// A traditional builder-style interface for constructing
/// a BSON document.
Expand Down
Loading