diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 00:22:50 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 10:56:02 -0400 |
commit | 9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch) | |
tree | 3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/bson/timestamp.h | |
parent | 01965cf52bce6976637ecb8f4a622aeb05ab256a (diff) | |
download | mongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz |
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/bson/timestamp.h')
-rw-r--r-- | src/mongo/bson/timestamp.h | 174 |
1 files changed, 89 insertions, 85 deletions
diff --git a/src/mongo/bson/timestamp.h b/src/mongo/bson/timestamp.h index 7ec80bb8488..47e2bf936e7 100644 --- a/src/mongo/bson/timestamp.h +++ b/src/mongo/bson/timestamp.h @@ -34,90 +34,94 @@ namespace mongo { +/** + * Timestamp: A combination of a count of seconds since the POSIX epoch plus an ordinal value. + */ +class Timestamp { +public: + // Maximum Timestamp value. + static Timestamp max(); + + /** + * DEPRECATED Constructor that builds a Timestamp from a Date_t by using the + * high-order 4 bytes of "date" for the "secs" field and the low-order 4 bytes + * for the "i" field. + */ + explicit Timestamp(Date_t date) : Timestamp(date.toULL()) {} + /** - * Timestamp: A combination of a count of seconds since the POSIX epoch plus an ordinal value. + * DEPRECATED Constructor that builds a Timestamp from a 64-bit unsigned integer by using + * the high-order 4 bytes of "v" for the "secs" field and the low-order 4 bytes for the "i" + * field. */ - class Timestamp { - public: - // Maximum Timestamp value. - static Timestamp max(); - - /** - * DEPRECATED Constructor that builds a Timestamp from a Date_t by using the - * high-order 4 bytes of "date" for the "secs" field and the low-order 4 bytes - * for the "i" field. - */ - explicit Timestamp(Date_t date) : Timestamp(date.toULL()) {} - - /** - * DEPRECATED Constructor that builds a Timestamp from a 64-bit unsigned integer by using - * the high-order 4 bytes of "v" for the "secs" field and the low-order 4 bytes for the "i" - * field. - */ - explicit Timestamp(unsigned long long v) : Timestamp(v >> 32, v) {} - - Timestamp(Seconds s, unsigned increment) : Timestamp(s.count(), increment) {} - - Timestamp(unsigned a, unsigned b) : i(b), secs(a) { - dassert(secs <= static_cast<unsigned>(std::numeric_limits<int>::max())); - } - - Timestamp() = default; - - unsigned getSecs() const { - return secs; - } - - unsigned getInc() const { - return i; - } - - unsigned long long asULL() const { - unsigned long long result = secs; - result <<= 32; - result |= i; - return result; - } - long long asLL() const { - return static_cast<long long>(asULL()); - } - - bool isNull() const { return secs == 0; } - - std::string toStringLong() const; - - std::string toStringPretty() const; - - std::string toString() const; - - bool operator==(const Timestamp& r) const { - return tie() == r.tie(); - } - bool operator!=(const Timestamp& r) const { - return tie() != r.tie(); - } - bool operator<(const Timestamp& r) const { - return tie() < r.tie(); - } - bool operator<=(const Timestamp& r) const { - return tie() <= r.tie(); - } - bool operator>(const Timestamp& r) const { - return tie() > r.tie(); - } - bool operator>=(const Timestamp& r) const { - return tie() >= r.tie(); - } - - // Append the BSON representation of this Timestamp to the given BufBuilder with the given - // name. This lives here because Timestamp manages its own serialization format. - void append(BufBuilder& builder, const StringData& fieldName) const; - - private: - std::tuple<unsigned, unsigned> tie() const { return std::tie(secs, i); } - - unsigned i = 0; - unsigned secs = 0; - }; - -} // namespace mongo + explicit Timestamp(unsigned long long v) : Timestamp(v >> 32, v) {} + + Timestamp(Seconds s, unsigned increment) : Timestamp(s.count(), increment) {} + + Timestamp(unsigned a, unsigned b) : i(b), secs(a) { + dassert(secs <= static_cast<unsigned>(std::numeric_limits<int>::max())); + } + + Timestamp() = default; + + unsigned getSecs() const { + return secs; + } + + unsigned getInc() const { + return i; + } + + unsigned long long asULL() const { + unsigned long long result = secs; + result <<= 32; + result |= i; + return result; + } + long long asLL() const { + return static_cast<long long>(asULL()); + } + + bool isNull() const { + return secs == 0; + } + + std::string toStringLong() const; + + std::string toStringPretty() const; + + std::string toString() const; + + bool operator==(const Timestamp& r) const { + return tie() == r.tie(); + } + bool operator!=(const Timestamp& r) const { + return tie() != r.tie(); + } + bool operator<(const Timestamp& r) const { + return tie() < r.tie(); + } + bool operator<=(const Timestamp& r) const { + return tie() <= r.tie(); + } + bool operator>(const Timestamp& r) const { + return tie() > r.tie(); + } + bool operator>=(const Timestamp& r) const { + return tie() >= r.tie(); + } + + // Append the BSON representation of this Timestamp to the given BufBuilder with the given + // name. This lives here because Timestamp manages its own serialization format. + void append(BufBuilder& builder, const StringData& fieldName) const; + +private: + std::tuple<unsigned, unsigned> tie() const { + return std::tie(secs, i); + } + + unsigned i = 0; + unsigned secs = 0; +}; + +} // namespace mongo |