index_model.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Copyright 2017 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/document/value.hpp>
  16. #include <bsoncxx/document/view_or_value.hpp>
  17. #include <mongocxx/options/index.hpp>
  18. #include <mongocxx/config/prelude.hpp>
  19. namespace mongocxx {
  20. MONGOCXX_INLINE_NAMESPACE_BEGIN
  21. ///
  22. /// Class representing an index on a MongoDB server.
  23. ///
  24. class MONGOCXX_API index_model {
  25. public:
  26. ///
  27. /// Initializes a new index_model over a mongocxx::collection.
  28. ///
  29. index_model(const bsoncxx::document::view_or_value& keys,
  30. const bsoncxx::document::view_or_value& options = {});
  31. index_model() = delete;
  32. ///
  33. /// Move constructs an index_model.
  34. ///
  35. index_model(index_model&&) noexcept;
  36. ///
  37. /// Move assigns an index_model.
  38. ///
  39. index_model& operator=(index_model&&) noexcept;
  40. ///
  41. /// Copy constructs an index_model.
  42. ///
  43. index_model(const index_model&);
  44. index_model& operator=(const index_model&) = delete;
  45. ///
  46. /// Destroys an index_model.
  47. ///
  48. ~index_model();
  49. ///
  50. /// Retrieves keys of an index_model.
  51. ///
  52. bsoncxx::document::view keys() const;
  53. ///
  54. /// Retrieves options of an index_model.
  55. ///
  56. bsoncxx::document::view options() const;
  57. private:
  58. bsoncxx::document::value _keys;
  59. bsoncxx::document::value _options;
  60. };
  61. MONGOCXX_INLINE_NAMESPACE_END
  62. } // namespace mongocxx
  63. #include <mongocxx/config/postlude.hpp>