|
- #pragma once
-
- #include <string>
- #include <cstddef>
- #include <iostream>
-
- #include <cpphibernate/config.h>
- #include <cppcore/misc/exception.h>
-
- namespace cpphibernate
- {
-
- /**
- * @brief Hibernate exception class.
- */
- struct exception
- : public cppcore::exception
- {
- using cppcore::exception::exception;
- };
-
- /**
- * @brief Represents a string with an fixed length.
- */
- template<size_t N>
- struct string
- : public std::string
- {
- static constexpr decltype(auto) max_size = N;
-
- using std::string::string;
- using std::string::operator=;
- };
-
- /**
- * @brief Timestamp class.
- */
- struct timestamp
- {
- uint64_t value;
-
- /**
- * @brief Default constructor.
- */
- inline timestamp() = default;
-
- /**
- * @brief Value constructor.
- */
- inline timestamp(uint64_t v);
-
- /**
- * @brief Value assignment constructor.
- */
- inline timestamp& operator=(const uint64_t& v);
-
- /**
- * @brief Impicit type conversion to base type.
- */
- inline operator uint64_t() const;
- };
-
-
- /**
- * @brief A typical UUID implementation.
- */
- struct uuid
- : public std::array<uint8_t, 16>
- {
- public:
- /**
- * @brief Default constructor.
- */
- inline uuid();
-
- /**
- * @brief Construtor to create a UUID from a string.
- *
- * @param[in] str String to create UUID from.
- */
- inline uuid(const std::string& str);
-
- /**
- * @brief Move constructor.
- */
- inline uuid(uuid&&) = default;
-
- /**
- * @brief Copy constructor.
- */
- inline uuid(const uuid&) = default;
-
- /**
- * @brief Move assignment constructor.
- */
- inline uuid& operator = (uuid&&) = default;
-
- /**
- * @brief Copy assignment constructor.
- */
- inline uuid& operator = (const uuid&) = default;
-
- /**
- * @brief Write the UUID to passed stream.
- *
- * @param[in] os Stream to write UUID to.
- */
- void to_string(std::ostream& os) const;
-
- /**
- * @brief Write the UUID to passed stream.
- *
- * @param[in] os Stream to write UUID to.
- *
- * @return Stream passed as parameter.
- */
- std::ostream& operator<<(std::ostream& os) const;
-
- public:
- /**
- * @brief Create an UUID object from an string.
- *
- * @param[in] str String to create UUID from.
- * @param[in] val Parameter to store converted object in
- *
- * @retval true If the convertion was successful.
- * @retval false If the string could not be converted.
- */
- static bool from_string(const std::string& str, uuid& val);
- };
-
- }
-
- #include "types.inl"
|