File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -1103,6 +1103,35 @@ namespace fossil {
11031103 return std::string (buffer);
11041104 }
11051105
1106+ /* *
1107+ * @brief Converts a double amount into a formatted money string.
1108+ *
1109+ * Example: 1234.56 -> "$1,234.56"
1110+ *
1111+ * @param amount Numeric amount to convert.
1112+ * @return Formatted money string.
1113+ */
1114+ static std::string money_to_string (double amount) {
1115+ char buf[128 ];
1116+ if (fossil_io_cstring_money_to_string (amount, buf, sizeof (buf)) != 0 ) {
1117+ return " " ;
1118+ }
1119+ return std::string (buf);
1120+ }
1121+
1122+ /* *
1123+ * @brief Parses a money string into a numeric double value.
1124+ *
1125+ * Example: "$1,234.56" -> 1234.56
1126+ *
1127+ * @param input Formatted money string.
1128+ * @param amount Reference to double to store numeric value.
1129+ * @return true on success, false on failure.
1130+ */
1131+ static bool string_to_money (const std::string &input, double &amount) {
1132+ return fossil_io_cstring_string_to_money (input.c_str (), &amount) == 0 ;
1133+ }
1134+
11061135 /* *
11071136 * Creates a copy of the given cstring.
11081137 *
You can’t perform that action at this time.
0 commit comments