Skip to content

Commit 9042326

Browse files
committed
add alpha parse info to the color parser as well, so that it can be used later, to e.g. force alpha, if it was parsed with alpha
1 parent c2a920d commit 9042326

File tree

3 files changed

+162
-93
lines changed

3 files changed

+162
-93
lines changed

src/helper/color.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ helper::expected<HSVColor, std::string> HSVColor::from_string(const std::string&
1313
const auto result = detail::get_hsv_color_from_string(value);
1414

1515
if (result.has_value()) {
16-
return result.value().first;
16+
return std::get<0>(result.value());
1717
}
1818

1919
return helper::unexpected<std::string>{ result.error() };
2020
}
2121

22-
helper::expected<std::pair<HSVColor, color::SerializeMode>, std::string> HSVColor::from_string_with_serialization(
22+
helper::expected<std::tuple<HSVColor, color::SerializeMode, bool>, std::string> HSVColor::from_string_with_info(
2323
const std::string& value
2424
) {
2525

@@ -60,13 +60,13 @@ helper::expected<Color, std::string> Color::from_string(const std::string& value
6060
const auto result = detail::get_color_from_string(value);
6161

6262
if (result.has_value()) {
63-
return result.value().first;
63+
return std::get<0>(result.value());
6464
}
6565

6666
return helper::unexpected<std::string>{ result.error() };
6767
}
6868

69-
helper::expected<std::pair<Color, color::SerializeMode>, std::string> Color::from_string_with_serialization(
69+
helper::expected<std::tuple<Color, color::SerializeMode, bool>, std::string> Color::from_string_with_info(
7070
const std::string& value
7171
) {
7272

src/helper/color.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ struct HSVColor {
5656

5757
[[nodiscard]] static helper::expected<HSVColor, std::string> from_string(const std::string& value);
5858

59-
[[nodiscard]] static helper::expected<std::pair<HSVColor, color::SerializeMode>, std::string>
60-
from_string_with_serialization(const std::string& value);
59+
[[nodiscard]] static helper::expected<std::tuple<HSVColor, color::SerializeMode, bool>, std::string>
60+
from_string_with_info(const std::string& value);
6161

6262
[[nodiscard]] Color to_rgb_color() const;
6363

@@ -129,8 +129,8 @@ struct Color {
129129

130130
[[nodiscard]] static helper::expected<Color, std::string> from_string(const std::string& value);
131131

132-
[[nodiscard]] static helper::expected<std::pair<Color, color::SerializeMode>, std::string>
133-
from_string_with_serialization(const std::string& value);
132+
[[nodiscard]] static helper::expected<std::tuple<Color, color::SerializeMode, bool>, std::string>
133+
from_string_with_info(const std::string& value);
134134

135135

136136
[[nodiscard]] HSVColor to_hsv_color() const;

0 commit comments

Comments
 (0)