MongoDB C++ Driver  mongocxx-3.5.1
All Classes Namespaces Functions Typedefs Enumerations Enumerator Friends Pages
oid.hpp
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 
15 #pragma once
16 
17 #include <array>
18 #include <ctime>
19 #include <string>
20 
21 #include <bsoncxx/stdx/string_view.hpp>
22 
23 #include <bsoncxx/config/prelude.hpp>
24 
25 namespace bsoncxx {
26 BSONCXX_INLINE_NAMESPACE_BEGIN
27 
38 class BSONCXX_API oid {
39  public:
43  oid();
44 
55  explicit oid(const char* bytes, std::size_t len);
56 
66  explicit oid(const bsoncxx::stdx::string_view& str);
67 
73  std::string to_string() const;
74 
82  friend BSONCXX_API bool BSONCXX_CALL operator<(const oid& lhs, const oid& rhs);
83  friend BSONCXX_API bool BSONCXX_CALL operator>(const oid& lhs, const oid& rhs);
84  friend BSONCXX_API bool BSONCXX_CALL operator<=(const oid& lhs, const oid& rhs);
85  friend BSONCXX_API bool BSONCXX_CALL operator>=(const oid& lhs, const oid& rhs);
86  friend BSONCXX_API bool BSONCXX_CALL operator==(const oid& lhs, const oid& rhs);
87  friend BSONCXX_API bool BSONCXX_CALL operator!=(const oid& lhs, const oid& rhs);
91 
97  std::time_t get_time_t() const;
98 
104  const char* bytes() const;
105 
106  private:
107  friend BSONCXX_PRIVATE int oid_compare(const oid& lhs, const oid& rhs);
108 
109  std::array<char, 12> _bytes;
110 };
111 
112 BSONCXX_INLINE_NAMESPACE_END
113 } // namespace bsoncxx
114 
115 #include <bsoncxx/config/postlude.hpp>
Represents a MongoDB ObjectId.
Definition: oid.hpp:38
std::string to_string(type rhs)
Returns a stringification of the given type.
Top level namespace for MongoDB C++ BSON functionality.
Definition: element.hpp:24