@@ -45,10 +45,10 @@ utils::StrExpected<SpeedGbps> parse_speed(const std::string &throughput) {
4545 }
4646
4747 auto [value, unit] = maybe_value_unit.value ();
48- if (unit == " Mbps " ) {
48+ if (unit == Speed<MBit, Second>:: get_suffix () ) {
4949 return SpeedGbps (Speed<MBit, Second>(value));
5050 }
51- if (unit == " Gbps " ) {
51+ if (unit == Speed<GBit, Second>:: get_suffix () ) {
5252 return SpeedGbps (value);
5353 }
5454 return std::unexpected (" Unsupported throughput unit: " + unit);
@@ -62,16 +62,16 @@ utils::StrExpected<TimeNs> parse_time(const std::string &time) {
6262 }
6363
6464 auto [value, unit] = maybe_value_unit.value ();
65- if (unit == " ns " ) {
65+ if (unit == Nanosecond::suffix ) {
6666 return TimeNs (value);
6767 }
68- if (unit == " us " ) {
68+ if (unit == Microsecond::suffix ) {
6969 return TimeNs (Time<Microsecond>(value));
7070 }
71- if (unit == " ms " ) {
71+ if (unit == Millisecond::suffix ) {
7272 return TimeNs (Time<Millisecond>(value));
7373 }
74- if (unit == " s " ) {
74+ if (unit == Second::suffix ) {
7575 return TimeNs (Time<Second>(value));
7676 }
7777 return std::unexpected (" Unsupported time unit: " + unit);
@@ -85,28 +85,28 @@ utils::StrExpected<SizeByte> parse_size(const std::string &size) {
8585 }
8686
8787 auto [value, unit] = maybe_value_unit.value ();
88- if (unit == " b " ) {
88+ if (unit == Bit::suffix ) {
8989 return SizeByte (Size<Bit>(value));
9090 }
91- if (unit == " B " ) {
91+ if (unit == Byte::suffix ) {
9292 return SizeByte (value);
9393 }
94- if (unit == " Kb " ) {
94+ if (unit == KBit::suffix ) {
9595 return SizeByte (Size<KBit>(value));
9696 }
97- if (unit == " KB " ) {
97+ if (unit == KByte::suffix ) {
9898 return SizeByte (Size<KByte>(value));
9999 }
100- if (unit == " Mb " ) {
100+ if (unit == MBit::suffix ) {
101101 return SizeByte (Size<MBit>(value));
102102 }
103- if (unit == " MB " ) {
103+ if (unit == MByte::suffix ) {
104104 return SizeByte (Size<MByte>(value));
105105 }
106- if (unit == " Gb " ) {
106+ if (unit == GBit::suffix ) {
107107 return SizeByte (Size<GBit>(value));
108108 }
109- if (unit == " GB " ) {
109+ if (unit == GByte::suffix ) {
110110 return SizeByte (Size<GByte>(value));
111111 }
112112 return std::unexpected (" Unsupported size unit: " + unit);
0 commit comments