susumu.yata
null+****@clear*****
Tue Dec 16 10:39:52 JST 2014
susumu.yata 2014-10-29 12:15:47 +0900 (Wed, 29 Oct 2014) New Revision: e41cc8af69b033a285f5385b88b6870678cf83f6 https://github.com/groonga/grnxx/commit/e41cc8af69b033a285f5385b88b6870678cf83f6 Message: Add a candidate of RowID. (#95) Added files: include/grnxx/new_types/row_id.hpp Added: include/grnxx/new_types/row_id.hpp (+62 -0) 100644 =================================================================== --- /dev/null +++ include/grnxx/new_types/row_id.hpp 2014-10-29 12:15:47 +0900 (5c5c56c) @@ -0,0 +1,62 @@ +#ifndef GRNXX_NEW_TYPES_ROW_ID_HPP +#define GRNXX_NEW_TYPES_ROW_ID_HPP + +#include <cstdint> +#include <limits> + +#include "grnxx/new_types/na.hpp" + +namespace grnxx { + +class RowID { + public: + RowID() = default; + ~RowID() = default; + + constexpr RowID(const RowID &) = default; + RowID &operator=(const RowID &) = default; + + explicit constexpr RowID(uint64_t value) : value_(value) {} + explicit constexpr RowID(NA) : value_(na_value()) {} + + constexpr uint64_t value() const { + return value_; + } + + constexpr bool is_min() const { + return value_ == min_value(); + } + constexpr bool is_max() const { + return value_ == max_value(); + } + constexpr bool is_na() const { + return value_ == na_value(); + } + + static constexpr RowID min() { + return RowID(min_value()); + } + static constexpr RowID max() { + return RowID(max_value()); + } + static constexpr RowID na() { + return RowID(NA()); + } + + static constexpr uint64_t min_value() { + return 0; + } + static constexpr uint64_t max_value() { + return std::numeric_limits<uint64_t>::max() - 1; + } + static constexpr uint64_t na_value() { + return std::numeric_limits<uint64_t>::max(); + } + + private: + uint64_t value_; +}; + +} // namespace grnxx + +#endif // GRNXX_NEW_TYPES_ROW_ID_HPP -------------- next part -------------- HTML����������������������������... 下载