From c310de844f9065efde88372e6868e371c76f4426 Mon Sep 17 00:00:00 2001 From: ehughsbaird <44244083+ehughsbaird@users.noreply.github.com> Date: Sun, 29 Oct 2023 17:49:32 +0000 Subject: [PATCH] Load item volume better Don't roll our own quantity parsing code in multiple places, just use the already written code that works better. --- src/assign.cpp | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/assign.cpp b/src/assign.cpp index e025ba64baed0..b707ed289980b 100644 --- a/src/assign.cpp +++ b/src/assign.cpp @@ -40,21 +40,7 @@ bool assign( const JsonObject &jo, const std::string &name, units::volume &val, } if( obj.has_string( name ) ) { - units::volume::value_type tmp; - std::string suffix; - std::istringstream str( obj.get_string( name ) ); - str.imbue( std::locale::classic() ); - str >> tmp >> suffix; - if( str.peek() != std::istringstream::traits_type::eof() ) { - obj.throw_error_at( name, "syntax error when specifying volume" ); - } - if( suffix == "ml" ) { - out = units::from_milliliter( tmp ); - } else if( suffix == "L" ) { - out = units::from_milliliter( tmp * 1000 ); - } else { - obj.throw_error_at( name, "unrecognized volumetric unit" ); - } + out = read_from_json_string( obj.get_member( name ), units::volume_units ); return true; }