helpers.hpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright 2014 MongoDB Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include <bsoncxx/builder/concatenate.hpp>
  16. #include <bsoncxx/document/view_or_value.hpp>
  17. #include <bsoncxx/config/prelude.hpp>
  18. namespace bsoncxx {
  19. BSONCXX_INLINE_NAMESPACE_BEGIN
  20. namespace builder {
  21. namespace stream {
  22. using bsoncxx::builder::concatenate;
  23. struct BSONCXX_API open_document_type {
  24. constexpr open_document_type() {}
  25. };
  26. ///
  27. /// A stream manipulator to open a subdocument.
  28. ///
  29. constexpr open_document_type open_document;
  30. struct BSONCXX_API close_document_type {
  31. constexpr close_document_type() {}
  32. };
  33. ///
  34. /// A stream manipulator to close a subdocument.
  35. ///
  36. constexpr close_document_type close_document;
  37. struct BSONCXX_API open_array_type {
  38. constexpr open_array_type() {}
  39. };
  40. ///
  41. /// A stream manipulator to open a subarray.
  42. ///
  43. /// @see https://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/working-with-bson/#builders for help
  44. /// building arrays in loops.
  45. ///
  46. constexpr open_array_type open_array;
  47. struct BSONCXX_API close_array_type {
  48. constexpr close_array_type() {}
  49. };
  50. ///
  51. /// A stream manipulator to close a subarray.
  52. ///
  53. constexpr close_array_type close_array;
  54. struct BSONCXX_API finalize_type {
  55. constexpr finalize_type() {}
  56. };
  57. ///
  58. /// A stream manipulator to finalize a document. When finalize is passed,
  59. /// the expression will evaluate to an owning document::value or array::value.
  60. ///
  61. constexpr finalize_type finalize;
  62. } // namespace stream
  63. } // namespace builder
  64. BSONCXX_INLINE_NAMESPACE_END
  65. } // namespace bsoncxx
  66. #include <bsoncxx/config/postlude.hpp>