aboutsummaryrefslogtreecommitdiff
path: root/src/openvic2/Types.cpp
diff options
context:
space:
mode:
author Hop311 <hop3114@gmail.com>2023-05-03 20:37:26 +0200
committer Hop311 <hop3114@gmail.com>2023-05-03 20:37:26 +0200
commit64bbf86b623a3cca2eaf9009d7acdcde067592e3 (patch)
tree5d607f28019675c9eaaa2883acf036717fa45b2f /src/openvic2/Types.cpp
parentc92481448159d3a363d6a99b3025bd2358c3dab6 (diff)
Moved code to src/openvic2
Diffstat (limited to 'src/openvic2/Types.cpp')
-rw-r--r--src/openvic2/Types.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/openvic2/Types.cpp b/src/openvic2/Types.cpp
new file mode 100644
index 0000000..f51ad7c
--- /dev/null
+++ b/src/openvic2/Types.cpp
@@ -0,0 +1,31 @@
+#include "Types.hpp"
+
+#include <cassert>
+#include <sstream>
+#include <iomanip>
+
+using namespace OpenVic2;
+
+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) : colour(new_colour) {
+ assert(colour != NULL_COLOUR && colour <= MAX_COLOUR_RGB);
+}
+
+colour_t HasColour::get_colour() const { return colour; }
+
+std::string OpenVic2::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);
+}