aboutsummaryrefslogtreecommitdiff
path: root/src/openvic2/Types.cpp
blob: 719f5b16d9817bba809ff6cd60e6df4dbc57db96 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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, 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 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);
}