mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 11:20:05 +00:00 
			
		
		
		
	Finish parsing storm tracking tabular block
This commit is contained in:
		
							parent
							
								
									6eb9caf819
								
							
						
					
					
						commit
						c03947d604
					
				
					 3 changed files with 184 additions and 44 deletions
				
			
		|  | @ -1,6 +1,9 @@ | |||
| #define STRINGS_IMPLEMENTATION | ||||
| 
 | ||||
| #include <scwx/util/strings.hpp> | ||||
| 
 | ||||
| #include <boost/algorithm/string/trim.hpp> | ||||
| #include <boost/lexical_cast.hpp> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
|  | @ -88,29 +91,15 @@ std::string ToString(const std::vector<std::string>& v) | |||
|    return value; | ||||
| } | ||||
| 
 | ||||
| std::optional<float> TryParseFloat(const std::string& str) | ||||
| { | ||||
|    std::optional<float> value = std::nullopt; | ||||
| 
 | ||||
|    try | ||||
|    { | ||||
|       value = static_cast<float>(std::stof(str)); | ||||
|    } | ||||
|    catch (const std::exception&) | ||||
|    { | ||||
|    } | ||||
| 
 | ||||
|    return value; | ||||
| } | ||||
| 
 | ||||
| template<typename T> | ||||
| std::optional<T> TryParseUnsignedLong(const std::string& str) | ||||
| std::optional<T> TryParseNumeric(const std::string& str) | ||||
| { | ||||
|    std::optional<T> value = std::nullopt; | ||||
| 
 | ||||
|    try | ||||
|    { | ||||
|       value = static_cast<T>(std::stoul(str)); | ||||
|       auto trimmed = boost::algorithm::trim_copy(str); | ||||
|       value        = boost::lexical_cast<T>(trimmed); | ||||
|    } | ||||
|    catch (const std::exception&) | ||||
|    { | ||||
|  | @ -119,8 +108,5 @@ std::optional<T> TryParseUnsignedLong(const std::string& str) | |||
|    return value; | ||||
| } | ||||
| 
 | ||||
| template std::optional<std::uint16_t> | ||||
| TryParseUnsignedLong<std::uint16_t>(const std::string& str); | ||||
| 
 | ||||
| } // namespace util
 | ||||
| } // namespace scwx
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat