| 57 | } |
| 58 | |
| 59 | static Expected<Color> parseColor( const std::string& s ) |
| 60 | { |
| 61 | if ( ( s.size() != 7 && s.size() != 9 ) || s[0] != '#' ) |
| 62 | return unexpected( "Invalid color format" ); |
| 63 | |
| 64 | Color res; |
| 65 | if ( std::from_chars( s.data() + 1, s.data() + 3, res.r, 16 ).ec != std::errc() ) |
| 66 | return unexpected( "Invalid color format" ); |
| 67 | |
| 68 | if ( std::from_chars( s.data() + 3, s.data() + 5, res.g, 16 ).ec != std::errc() ) |
| 69 | return unexpected( "Invalid color format" ); |
| 70 | |
| 71 | if ( std::from_chars( s.data() + 5, s.data() + 7, res.b, 16 ).ec != std::errc() ) |
| 72 | return unexpected( "Invalid color format" ); |
| 73 | |
| 74 | if ( s.size() == 9 ) |
| 75 | if ( std::from_chars( s.data() + 7, s.data() + 9, res.a, 16 ).ec != std::errc() ) |
| 76 | return unexpected( "Invalid color format" ); |
| 77 | |
| 78 | return res; |
| 79 | } |
| 80 | |
| 81 | enum class NodeType |
| 82 | { |
no test coverage detected