MCPcopy Create free account
hub / github.com/beginner-jhj/mini_browser / parse_string_to_float

Method parse_string_to_float

src/css/computed_style.cpp:628–639  ·  view source on GitHub ↗

* \brief Parses a CSS numeric value string with units into a float. * * Converts string representations of numbers (with or without units) into * floating-point values. Handles invalid input gracefully by returning the * provided default value. * * \param value The numeric string to parse (e.g., "10px", "15.5"). * \param default_value The value to return if parsing fails. * \return The par

Source from the content-addressed store, hash-verified

626 * \return The parsed float value, or default_value on error.
627 */
628float COMPUTED_STYLE::parse_string_to_float(const std::string &value, const float default_value)
629{
630 try
631 {
632 float num_value = std::stof(value);
633 return num_value;
634 }
635 catch (...)
636 {
637 return default_value;
638 }
639}
640
641/**
642 * \brief Returns the inherited color value as a hex string.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected