Skip to content

Commit ed1329d

Browse files
authored
CXX-3069 document headers and root namespace redeclarations (bsoncxx) (#1182)
* Address -Wzero-as-null-pointer-constant warnings * Address -Wundef warnings * Restrict Doxygen examples to examples/ * Fix Doxygen docs and parsing in stdx and config headers * Partially fix docs for bsoncxx::v_noabi::error_code * CXX-3069 document headers and redeclarations (bsoncxx) * Update examples to avoid using stdx::make_unique * Address -Wmissing-include-dirs warnings for examples
1 parent c6dca66 commit ed1329d

File tree

95 files changed

+2046
-612
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+2046
-612
lines changed

Doxyfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,7 @@ RECURSIVE = YES
901901
# Note that relative paths are relative to the directory from which doxygen is
902902
# run.
903903

904-
EXCLUDE = src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/operators.hpp \
905-
src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/type_traits.hpp
904+
EXCLUDE =
906905

907906
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
908907
# directories that are symbolic links (a Unix file system feature) are excluded
@@ -938,7 +937,7 @@ EXCLUDE_SYMBOLS = bsoncxx::detail \
938937
# that contain example code fragments that are included (see the \include
939938
# command).
940939

941-
EXAMPLE_PATH = .
940+
EXAMPLE_PATH = examples
942941

943942
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
944943
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and

examples/bsoncxx/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
include_directories(
16-
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/v_noabi
17-
)
18-
1915
set(BSONCXX_EXAMPLES
2016
builder_core.cpp
2117
builder_list.cpp

examples/mongocxx/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
include_directories(
16-
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/v_noabi
17-
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/mongocxx/v_noabi
18-
)
19-
2015
set(MONGOCXX_EXAMPLES
2116
aggregate.cpp
2217
automatic_client_side_field_level_encryption.cpp

examples/mongocxx/connect.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <bsoncxx/builder/basic/document.hpp>
2020
#include <bsoncxx/builder/basic/kvp.hpp>
2121
#include <bsoncxx/json.hpp>
22-
#include <bsoncxx/stdx/make_unique.hpp>
2322
#include <mongocxx/client.hpp>
2423
#include <mongocxx/instance.hpp>
2524
#include <mongocxx/logger.hpp>
@@ -44,6 +43,11 @@ class logger final : public mongocxx::logger {
4443
std::ostream* const _stream;
4544
};
4645

46+
// Use `std::make_unique` with C++14 and newer.
47+
std::unique_ptr<logger> make_logger() {
48+
return std::unique_ptr<logger>(new logger(&std::cout));
49+
}
50+
4751
} // namespace
4852

4953
int main(int argc, char* argv[]) {
@@ -53,7 +57,7 @@ int main(int argc, char* argv[]) {
5357
// The mongocxx::instance constructor and destructor initialize and shut down the driver,
5458
// respectively. Therefore, a mongocxx::instance must be created before using the driver and
5559
// must remain alive for as long as the driver is in use.
56-
mongocxx::instance inst{bsoncxx::stdx::make_unique<logger>(&std::cout)};
60+
mongocxx::instance inst{make_logger()};
5761

5862
try {
5963
const auto uri = mongocxx::uri{(argc >= 2) ? argv[1] : mongocxx::uri::k_default_uri};

examples/mongocxx/gridfs.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@
1717
#include <ostream>
1818

1919
#include <bsoncxx/json.hpp>
20-
#include <bsoncxx/stdx/make_unique.hpp>
2120
#include <mongocxx/client.hpp>
2221
#include <mongocxx/gridfs/bucket.hpp>
2322
#include <mongocxx/instance.hpp>
2423
#include <mongocxx/uri.hpp>
2524

2625
using namespace mongocxx;
2726

28-
using bsoncxx::stdx::make_unique;
29-
3027
int main() {
3128
// The mongocxx::instance constructor and destructor initialize and shut down the driver,
3229
// respectively. Therefore, a mongocxx::instance must be created before using the driver and
@@ -61,7 +58,9 @@ int main() {
6158
auto bytes_counter = 0;
6259

6360
auto buffer_size = std::min(file_length, static_cast<std::int64_t>(downloader.chunk_size()));
64-
auto buffer = make_unique<std::uint8_t[]>(static_cast<std::size_t>(buffer_size));
61+
62+
// Use `std::make_unique` with C++14 and newer.
63+
auto buffer = std::unique_ptr<std::uint8_t[]>(new std::uint8_t[buffer_size]);
6564

6665
while (auto length_read =
6766
downloader.read(buffer.get(), static_cast<std::size_t>(buffer_size))) {

examples/mongocxx/index.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#include <bsoncxx/builder/basic/document.hpp>
1616
#include <bsoncxx/builder/basic/kvp.hpp>
17-
#include <bsoncxx/stdx/make_unique.hpp>
1817
#include <mongocxx/client.hpp>
1918
#include <mongocxx/instance.hpp>
2019
#include <mongocxx/uri.hpp>
@@ -58,8 +57,11 @@ int main(int, char**) {
5857
{
5958
db["restaurants"].drop();
6059
mongocxx::options::index index_options{};
61-
std::unique_ptr<mongocxx::options::index::wiredtiger_storage_options> wt_options =
62-
bsoncxx::stdx::make_unique<mongocxx::options::index::wiredtiger_storage_options>();
60+
61+
// Use `std::make_unique` with C++14 and newer.
62+
std::unique_ptr<mongocxx::options::index::wiredtiger_storage_options> wt_options{
63+
new mongocxx::options::index::wiredtiger_storage_options()};
64+
6365
wt_options->config_string("block_allocation=first");
6466
index_options.storage_options(std::move(wt_options));
6567
db["restaurants"].create_index(make_document(kvp("cuisine", 1)), index_options);

examples/mongocxx/instance_management.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
#include <cstdlib>
1616
#include <memory>
17+
#include <type_traits>
1718

18-
#include <bsoncxx/stdx/make_unique.hpp>
1919
#include <bsoncxx/stdx/optional.hpp>
2020
#include <bsoncxx/stdx/string_view.hpp>
2121
#include <mongocxx/instance.hpp>
@@ -80,11 +80,14 @@ void configure(mongocxx::uri uri) {
8080
bsoncxx::stdx::string_view) noexcept {}
8181
};
8282

83-
auto instance =
84-
bsoncxx::stdx::make_unique<mongocxx::instance>(bsoncxx::stdx::make_unique<noop_logger>());
83+
// Use `std::make_unique` with C++14 and newer.
84+
auto instance = std::unique_ptr<mongocxx::instance>(
85+
new mongocxx::instance(std::unique_ptr<noop_logger>(new noop_logger())));
8586

86-
mongo_access::instance().configure(std::move(instance),
87-
bsoncxx::stdx::make_unique<mongocxx::pool>(std::move(uri)));
87+
// Use `std::make_unique` with C++14 and newer.
88+
auto pool = std::unique_ptr<mongocxx::pool>(new mongocxx::pool(std::move(uri)));
89+
90+
mongo_access::instance().configure(std::move(instance), std::move(pool));
8891
}
8992

9093
bool do_work() {

examples/mongocxx/view_or_value_variant.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <bsoncxx/builder/basic/array.hpp>
1616
#include <bsoncxx/builder/basic/document.hpp>
1717
#include <bsoncxx/builder/basic/kvp.hpp>
18-
#include <bsoncxx/stdx/make_unique.hpp>
1918
#include <mongocxx/client.hpp>
2019
#include <mongocxx/instance.hpp>
2120
#include <mongocxx/stdx.hpp>

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/element-fwd.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,21 @@ using ::bsoncxx::v_noabi::array::element;
3535
} // namespace bsoncxx
3636

3737
#include <bsoncxx/config/postlude.hpp>
38+
39+
///
40+
/// @file
41+
/// Declares @ref bsoncxx::v_noabi::array::element.
42+
///
43+
44+
#if defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
45+
46+
namespace bsoncxx {
47+
namespace array {
48+
49+
/// @ref bsoncxx::v_noabi::array::element
50+
class element {};
51+
52+
} // namespace array
53+
} // namespace bsoncxx
54+
55+
#endif // defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/element.hpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,30 @@ using ::bsoncxx::v_noabi::array::operator!=;
124124
} // namespace bsoncxx
125125

126126
#include <bsoncxx/config/postlude.hpp>
127+
128+
///
129+
/// @file
130+
/// Provides @ref bsoncxx::v_noabi::array::element.
131+
///
132+
133+
#if defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
134+
135+
namespace bsoncxx {
136+
namespace array {
137+
138+
/// @ref bsoncxx::v_noabi::array::operator==(const v_noabi::array::element& elem, const v_noabi::types::bson_value::view& v)
139+
bool operator==(const v_noabi::array::element& elem, const v_noabi::types::bson_value::view& v);
140+
141+
/// @ref bsoncxx::v_noabi::array::operator==(const v_noabi::types::bson_value::view& v, const v_noabi::array::element& elem)
142+
bool operator==(const v_noabi::types::bson_value::view& v, const v_noabi::array::element& elem);
143+
144+
/// @ref bsoncxx::v_noabi::array::operator!=(const v_noabi::array::element& elem, const v_noabi::types::bson_value::view& v)
145+
bool operator!=(const v_noabi::array::element& elem, const v_noabi::types::bson_value::view& v);
146+
147+
/// @ref bsoncxx::v_noabi::array::operator!=(const v_noabi::types::bson_value::view& v, const v_noabi::array::element& elem)
148+
bool operator!=(const v_noabi::types::bson_value::view& v, const v_noabi::array::element& elem);
149+
150+
} // namespace array
151+
} // namespace bsoncxx
152+
153+
#endif // defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/value-fwd.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,21 @@ using ::bsoncxx::v_noabi::array::value;
3535
} // namespace bsoncxx
3636

3737
#include <bsoncxx/config/postlude.hpp>
38+
39+
///
40+
/// @file
41+
/// Declares @ref bsoncxx::v_noabi::array::value.
42+
///
43+
44+
#if defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
45+
46+
namespace bsoncxx {
47+
namespace array {
48+
49+
/// @ref bsoncxx::v_noabi::array::value
50+
class value {};
51+
52+
} // namespace array
53+
} // namespace bsoncxx
54+
55+
#endif // defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/value.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,8 @@ BSONCXX_INLINE value::operator array::view() const noexcept {
120120
} // namespace bsoncxx
121121

122122
#include <bsoncxx/config/postlude.hpp>
123+
124+
///
125+
/// @file
126+
/// Provides @ref bsoncxx::v_noabi::array::value.
127+
///

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/view-fwd.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,21 @@ using ::bsoncxx::v_noabi::array::view;
3535
} // namespace bsoncxx
3636

3737
#include <bsoncxx/config/postlude.hpp>
38+
39+
///
40+
/// @file
41+
/// Declares @ref bsoncxx::v_noabi::array::view.
42+
///
43+
44+
#if defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
45+
46+
namespace bsoncxx {
47+
namespace array {
48+
49+
/// @ref bsoncxx::v_noabi::array::view
50+
class view {};
51+
52+
} // namespace array
53+
} // namespace bsoncxx
54+
55+
#endif // defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/view.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,8 @@ class view::const_iterator {
190190
} // namespace bsoncxx
191191

192192
#include <bsoncxx/config/postlude.hpp>
193+
194+
///
195+
/// @file
196+
/// Provides @ref bsoncxx::v_noabi::array::view.
197+
///

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/view_or_value.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,21 @@ using ::bsoncxx::v_noabi::array::view_or_value;
4343
} // namespace bsoncxx
4444

4545
#include <bsoncxx/config/postlude.hpp>
46+
47+
///
48+
/// @file
49+
/// Provides @ref bsoncxx::v_noabi::array::view_or_value.
50+
///
51+
52+
#if defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
53+
54+
namespace bsoncxx {
55+
namespace array {
56+
57+
/// @ref bsoncxx::v_noabi::array::view_or_value
58+
class view_or_value {};
59+
60+
} // namespace array
61+
} // namespace bsoncxx
62+
63+
#endif // defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/array-fwd.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,23 @@ using ::bsoncxx::v_noabi::builder::basic::array;
3535
} // namespace basic
3636
} // namespace builder
3737
} // namespace bsoncxx
38+
39+
///
40+
/// @file
41+
/// Declares @ref bsoncxx::v_noabi::builder::basic::array.
42+
///
43+
44+
#if defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
45+
46+
namespace bsoncxx {
47+
namespace builder {
48+
namespace basic {
49+
50+
/// @ref bsoncxx::v_noabi::builder::basic::array
51+
class array {};
52+
53+
} // namespace basic
54+
} // namespace builder
55+
} // namespace bsoncxx
56+
57+
#endif // defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/array.hpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,24 @@ using ::bsoncxx::v_noabi::builder::basic::make_array;
136136
} // namespace bsoncxx
137137

138138
#include <bsoncxx/config/postlude.hpp>
139+
140+
///
141+
/// @file
142+
/// Provides @ref bsoncxx::v_noabi::builder::basic::array.
143+
///
144+
145+
#if defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
146+
147+
namespace bsoncxx {
148+
namespace builder {
149+
namespace basic {
150+
151+
/// @ref bsoncxx::v_noabi::builder::basic::make_array
152+
template <typename... Args>
153+
v_noabi::array::value make_array(Args&&... args);
154+
155+
} // namespace basic
156+
} // namespace builder
157+
} // namespace bsoncxx
158+
159+
#endif // defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/document-fwd.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,23 @@ using ::bsoncxx::v_noabi::builder::basic::document;
3535
} // namespace basic
3636
} // namespace builder
3737
} // namespace bsoncxx
38+
39+
///
40+
/// @file
41+
/// Declares @ref bsoncxx::v_noabi::builder::basic::document.
42+
///
43+
44+
#if defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
45+
46+
namespace bsoncxx {
47+
namespace builder {
48+
namespace basic {
49+
50+
/// @ref bsoncxx::v_noabi::builder::basic::document
51+
class document {};
52+
53+
} // namespace basic
54+
} // namespace builder
55+
} // namespace bsoncxx
56+
57+
#endif // defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/document.hpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,24 @@ using ::bsoncxx::v_noabi::builder::basic::make_document;
135135
} // namespace bsoncxx
136136

137137
#include <bsoncxx/config/postlude.hpp>
138+
139+
///
140+
/// @file
141+
/// Provides @ref bsoncxx::v_noabi::builder::basic::document.
142+
///
143+
144+
#if defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
145+
146+
namespace bsoncxx {
147+
namespace builder {
148+
namespace basic {
149+
150+
/// @ref bsoncxx::v_noabi::builder::basic::make_document
151+
template <typename... Args>
152+
v_noabi::document::value make_document(Args&&... args);
153+
154+
} // namespace basic
155+
} // namespace builder
156+
} // namespace bsoncxx
157+
158+
#endif // defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)

0 commit comments

Comments
 (0)