From 42d9d1d5417deb5979a9d5775cfe97dcff4b77ba Mon Sep 17 00:00:00 2001 From: Hop311 Date: Tue, 16 May 2023 19:59:39 +0100 Subject: Changed from OpenVic2 to OpenVic --- src/openvic/Types.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/openvic/Types.cpp (limited to 'src/openvic/Types.cpp') diff --git a/src/openvic/Types.cpp b/src/openvic/Types.cpp new file mode 100644 index 0000000..829770b --- /dev/null +++ b/src/openvic/Types.cpp @@ -0,0 +1,31 @@ +#include "Types.hpp" + +#include +#include +#include + +using namespace OpenVic; + +HasIdentifier::HasIdentifier(std::string const& new_identifier) : identifier{ new_identifier } { + assert(!identifier.empty()); +} + +std::string const& HasIdentifier::get_identifier() const { + return identifier; +} + +HasColour::HasColour(colour_t const new_colour, bool can_be_null) : colour(new_colour) { + assert((can_be_null || colour != NULL_COLOUR) && colour <= MAX_COLOUR_RGB); +} + +colour_t HasColour::get_colour() const { return colour; } + +std::string HasColour::colour_to_hex_string(colour_t const colour) { + std::ostringstream stream; + stream << std::hex << std::setfill('0') << std::setw(6) << colour; + return stream.str(); +} + +std::string HasColour::colour_to_hex_string() const { + return colour_to_hex_string(colour); +} -- cgit v1.2.3-56-ga3b1