Skip to content

Commit ab15de1

Browse files
authored
CXX-3102 Remove use of BSONCXX_ENUM in public headers (#1207)
* doxygen: set MULTILINE_CPP_IS_BRIEF = YES * doxygen: set ENUM_VALUES_PER_LINE = 1 * Fix reference to bsoncxx::v_noabi::bson_value::view * Fix missing brief docs * Replace use of BSONCXX_ENUM in public headers * Use \showenumvalues instead of SHOW_ENUM_VALUES
1 parent 591e46d commit ab15de1

File tree

7 files changed

+210
-111
lines changed

7 files changed

+210
-111
lines changed

Doxyfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ QT_AUTOBRIEF = NO
237237
# not recognized any more.
238238
# The default value is: NO.
239239

240-
MULTILINE_CPP_IS_BRIEF = NO
240+
MULTILINE_CPP_IS_BRIEF = YES
241241

242242
# By default Python docstrings are displayed as preformatted text and doxygen's
243243
# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the
@@ -1726,7 +1726,7 @@ FULL_SIDEBAR = NO
17261726
# Minimum value: 0, maximum value: 20, default value: 4.
17271727
# This tag requires that the tag GENERATE_HTML is set to YES.
17281728

1729-
ENUM_VALUES_PER_LINE = 4
1729+
ENUM_VALUES_PER_LINE = 0
17301730

17311731
# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used
17321732
# to set the initial width (in pixels) of the frame in which the tree is shown.

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/exception/error_code.hpp

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,30 @@ enum class error_code : std::int32_t {
4343
/// A document operation was performed while building an array.
4444
k_cannot_perform_document_operation_on_array,
4545

46-
// @cond DOXYGEN_DISABLE
47-
#define BSONCXX_ENUM(name, value) k_need_element_type_k_##name,
48-
#include <bsoncxx/enums/type.hpp>
49-
#undef BSONCXX_ENUM
50-
// @endcond DOXYGEN_DISABLE
46+
/// The underlying value does not have the requested type.
47+
/// @{
48+
k_need_element_type_k_double,
49+
k_need_element_type_k_string,
50+
k_need_element_type_k_document,
51+
k_need_element_type_k_array,
52+
k_need_element_type_k_binary,
53+
k_need_element_type_k_undefined,
54+
k_need_element_type_k_oid,
55+
k_need_element_type_k_bool,
56+
k_need_element_type_k_date,
57+
k_need_element_type_k_null,
58+
k_need_element_type_k_regex,
59+
k_need_element_type_k_dbpointer,
60+
k_need_element_type_k_code,
61+
k_need_element_type_k_symbol,
62+
k_need_element_type_k_codewscope,
63+
k_need_element_type_k_int32,
64+
k_need_element_type_k_timestamp,
65+
k_need_element_type_k_int64,
66+
k_need_element_type_k_decimal128,
67+
k_need_element_type_k_maxkey,
68+
k_need_element_type_k_minkey,
69+
/// @}
5170

5271
/// No key was provided when one was needed.
5372
k_need_key,
@@ -97,13 +116,32 @@ enum class error_code : std::int32_t {
97116
/// Invalid type.
98117
k_invalid_bson_type_id,
99118

100-
// @cond DOXYGEN_DISABLE
101-
#define BSONCXX_ENUM(name, value) k_cannot_append_##name,
102-
#include <bsoncxx/enums/type.hpp>
103-
#undef BSONCXX_ENUM
104-
// @endcond DOXYGEN_DISABLE
105-
106-
/// A value failed to append.
119+
/// Failed to append a value of the given type.
120+
/// @{
121+
k_cannot_append_double,
122+
k_cannot_append_string,
123+
k_cannot_append_document,
124+
k_cannot_append_array,
125+
k_cannot_append_binary,
126+
k_cannot_append_undefined,
127+
k_cannot_append_oid,
128+
k_cannot_append_bool,
129+
k_cannot_append_date,
130+
k_cannot_append_null,
131+
k_cannot_append_regex,
132+
k_cannot_append_dbpointer,
133+
k_cannot_append_code,
134+
k_cannot_append_symbol,
135+
k_cannot_append_codewscope,
136+
k_cannot_append_int32,
137+
k_cannot_append_timestamp,
138+
k_cannot_append_int64,
139+
k_cannot_append_decimal128,
140+
k_cannot_append_maxkey,
141+
k_cannot_append_minkey,
142+
/// @}
143+
144+
/// Failed to append a value of the given type.
107145
k_cannot_append_utf8 = k_cannot_append_string,
108146

109147
/// @deprecated Use `k_need_element_type_k_string` instead.

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types-fwd.hpp

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,27 @@ namespace bsoncxx {
3131
namespace v_noabi {
3232
namespace types {
3333

34-
#pragma push_macro("BSONCXX_ENUM")
35-
#undef BSONCXX_ENUM
36-
#define BSONCXX_ENUM(name, val) struct b_##name;
37-
#include <bsoncxx/enums/type.hpp>
38-
#undef BSONCXX_ENUM
39-
#pragma pop_macro("BSONCXX_ENUM")
34+
struct b_double;
35+
struct b_string;
36+
struct b_document;
37+
struct b_array;
38+
struct b_binary;
39+
struct b_undefined;
40+
struct b_oid;
41+
struct b_bool;
42+
struct b_date;
43+
struct b_null;
44+
struct b_regex;
45+
struct b_dbpointer;
46+
struct b_code;
47+
struct b_symbol;
48+
struct b_codewscope;
49+
struct b_int32;
50+
struct b_timestamp;
51+
struct b_int64;
52+
struct b_decimal128;
53+
struct b_maxkey;
54+
struct b_minkey;
4055

4156
} // namespace types
4257
} // namespace v_noabi
@@ -52,12 +67,27 @@ using ::bsoncxx::v_noabi::type;
5267
namespace bsoncxx {
5368
namespace types {
5469

55-
#pragma push_macro("BSONCXX_ENUM")
56-
#undef BSONCXX_ENUM
57-
#define BSONCXX_ENUM(name, val) using ::bsoncxx::v_noabi::types::b_##name;
58-
#include <bsoncxx/enums/type.hpp>
59-
#undef BSONCXX_ENUM
60-
#pragma pop_macro("BSONCXX_ENUM")
70+
using ::bsoncxx::v_noabi::types::b_array;
71+
using ::bsoncxx::v_noabi::types::b_binary;
72+
using ::bsoncxx::v_noabi::types::b_bool;
73+
using ::bsoncxx::v_noabi::types::b_code;
74+
using ::bsoncxx::v_noabi::types::b_codewscope;
75+
using ::bsoncxx::v_noabi::types::b_date;
76+
using ::bsoncxx::v_noabi::types::b_dbpointer;
77+
using ::bsoncxx::v_noabi::types::b_decimal128;
78+
using ::bsoncxx::v_noabi::types::b_document;
79+
using ::bsoncxx::v_noabi::types::b_double;
80+
using ::bsoncxx::v_noabi::types::b_int32;
81+
using ::bsoncxx::v_noabi::types::b_int64;
82+
using ::bsoncxx::v_noabi::types::b_maxkey;
83+
using ::bsoncxx::v_noabi::types::b_minkey;
84+
using ::bsoncxx::v_noabi::types::b_null;
85+
using ::bsoncxx::v_noabi::types::b_oid;
86+
using ::bsoncxx::v_noabi::types::b_regex;
87+
using ::bsoncxx::v_noabi::types::b_string;
88+
using ::bsoncxx::v_noabi::types::b_symbol;
89+
using ::bsoncxx::v_noabi::types::b_timestamp;
90+
using ::bsoncxx::v_noabi::types::b_undefined;
6191

6292
} // namespace types
6393
} // namespace bsoncxx

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types.hpp

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929

3030
#include <bsoncxx/config/prelude.hpp>
3131

32-
#pragma push_macro("BSONCXX_ENUM")
33-
#undef BSONCXX_ENUM
34-
3532
BSONCXX_PUSH_WARNINGS();
3633
BSONCXX_DISABLE_WARNING(GNU("-Wfloat-equal"));
3734

@@ -40,36 +37,50 @@ namespace v_noabi {
4037

4138
///
4239
/// An enumeration of each BSON type.
43-
/// These x-macros will expand to be of the form:
44-
/// k_double = 0x01,
45-
/// k_string = 0x02,
46-
/// k_document = 0x03,
47-
/// k_array = 0x04 ...
40+
///
41+
/// @showenumvalues
4842
///
4943
enum class type : std::uint8_t {
50-
#define BSONCXX_ENUM(name, val) k_##name = val,
51-
#include <bsoncxx/enums/type.hpp>
52-
#undef BSONCXX_ENUM
53-
k_utf8 = 0x02,
44+
k_double = 0x01, ///< 64-bit binary floating point.
45+
k_string = 0x02, ///< UTF-8 string.
46+
k_utf8 = 0x02, ///< Equivalent to @ref k_string. @deprecated
47+
k_document = 0x03, ///< Embedded document.
48+
k_array = 0x04, ///< Array.
49+
k_binary = 0x05, ///< Binary data.
50+
k_undefined = 0x06, ///< Undefined value. @deprecated
51+
k_oid = 0x07, ///< ObjectId.
52+
k_bool = 0x08, ///< Boolean.
53+
k_date = 0x09, ///< UTC datetime.
54+
k_null = 0x0A, ///< Null value.
55+
k_regex = 0x0B, ///< Regular expression.
56+
k_dbpointer = 0x0C, ///< DBPointer. @deprecated
57+
k_code = 0x0D, ///< JavaScript code.
58+
k_symbol = 0x0E, ///< Symbol. @deprecated
59+
k_codewscope = 0x0F, ///< JavaScript code with scope.
60+
k_int32 = 0x10, ///< 32-bit integer.
61+
k_timestamp = 0x11, ///< Timestamp.
62+
k_int64 = 0x12, ///< 64-bit integer.
63+
k_decimal128 = 0x13, ///< 128-bit decimal floating point.
64+
k_maxkey = 0x7F, ///< Min key.
65+
k_minkey = 0xFF, ///< Max key.
5466
};
5567

5668
///
5769
/// An enumeration of each BSON binary sub type.
58-
/// These x-macros will expand to be of the form:
59-
/// k_binary = 0x00,
60-
/// k_function = 0x01,
61-
/// k_binary_deprecated = 0x02,
62-
/// k_uuid_deprecated = 0x03,
63-
/// k_uuid = 0x04,
64-
/// k_md5 = 0x05,
65-
/// k_encrypted = 0x06,
66-
/// k_column = 0x07,
67-
/// k_user = 0x80
70+
///
71+
/// @showenumvalues
6872
///
6973
enum class binary_sub_type : std::uint8_t {
70-
#define BSONCXX_ENUM(name, val) k_##name = val,
71-
#include <bsoncxx/enums/binary_sub_type.hpp>
72-
#undef BSONCXX_ENUM
74+
k_binary = 0x00, ///< Generic binary subtype.
75+
k_function = 0x01, ///< Function.
76+
k_binary_deprecated = 0x02, ///< Binary (Old). @deprecated
77+
k_uuid_deprecated = 0x03, ///< UUID (Old). @deprecated
78+
k_uuid = 0x04, ///< UUID.
79+
k_md5 = 0x05, ///< MD5.
80+
k_encrypted = 0x06, ///< Encrypted BSON value.
81+
k_column = 0x07, ///< Compressed BSON column.
82+
k_sensitive = 0x08, ///< Sensitive.
83+
k_user = 0x80, ///< User defined.
7384
};
7485

7586
///
@@ -871,11 +882,6 @@ using ::bsoncxx::v_noabi::types::operator!=;
871882
} // namespace types
872883
} // namespace bsoncxx
873884

874-
#ifdef BSONCXX_ENUM
875-
static_assert(false, "BSONCXX_ENUM must be undef'ed");
876-
#endif
877-
#pragma pop_macro("BSONCXX_ENUM")
878-
879885
#include <bsoncxx/config/postlude.hpp>
880886

881887
///

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/bson_value/value.hpp

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,37 @@ namespace bson_value {
4242
/// For accessors into this type and to extract the various BSON types out,
4343
/// please use bson_value::view.
4444
///
45-
/// @see bsoncxx::v_noabi::bson_value::view
45+
/// @see @ref bsoncxx::v_noabi::types::bson_value::view
4646
///
4747
class value {
4848
public:
49-
///
50-
/// Constructor for each BSON type.
51-
///
52-
/// These x-macros will expand to:
53-
/// value(b_double v);
54-
/// value(b_string v);
55-
/// value(b_document v);
56-
/// value(b_array v); ...
57-
///
58-
#define BSONCXX_ENUM(name, val) BSONCXX_ABI_EXPORT_CDECL() value(b_##name v);
59-
#include <bsoncxx/enums/type.hpp>
60-
#undef BSONCXX_ENUM
49+
///
50+
/// Construct a bson_value::value from the provided BSON type.
51+
///
52+
/// @{
53+
BSONCXX_ABI_EXPORT_CDECL() value(b_double v);
54+
BSONCXX_ABI_EXPORT_CDECL() value(b_string v);
55+
BSONCXX_ABI_EXPORT_CDECL() value(b_document v);
56+
BSONCXX_ABI_EXPORT_CDECL() value(b_array v);
57+
BSONCXX_ABI_EXPORT_CDECL() value(b_binary v);
58+
BSONCXX_ABI_EXPORT_CDECL() value(b_undefined v);
59+
BSONCXX_ABI_EXPORT_CDECL() value(b_oid v);
60+
BSONCXX_ABI_EXPORT_CDECL() value(b_bool v);
61+
BSONCXX_ABI_EXPORT_CDECL() value(b_date v);
62+
BSONCXX_ABI_EXPORT_CDECL() value(b_null);
63+
BSONCXX_ABI_EXPORT_CDECL() value(b_regex v);
64+
BSONCXX_ABI_EXPORT_CDECL() value(b_dbpointer v);
65+
BSONCXX_ABI_EXPORT_CDECL() value(b_code v);
66+
BSONCXX_ABI_EXPORT_CDECL() value(b_symbol v);
67+
BSONCXX_ABI_EXPORT_CDECL() value(b_codewscope v);
68+
BSONCXX_ABI_EXPORT_CDECL() value(b_int32 v);
69+
BSONCXX_ABI_EXPORT_CDECL() value(b_timestamp v);
70+
BSONCXX_ABI_EXPORT_CDECL() value(b_int64 v);
71+
BSONCXX_ABI_EXPORT_CDECL() value(b_decimal128 v);
72+
BSONCXX_ABI_EXPORT_CDECL() value(b_maxkey v);
73+
BSONCXX_ABI_EXPORT_CDECL() value(b_minkey v);
74+
/// @}
75+
///
6176

6277
///
6378
/// Constructs a BSON UTF-8 string value.

0 commit comments

Comments
 (0)