From 5c9991be21f57781573f04961ec511ac2938ea3d Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 08 四月 2025 15:27:08 +0800
Subject: [PATCH] '功能完善'

---
 common/StringUtil.h |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/common/StringUtil.h b/common/StringUtil.h
index bad5142..4778e5c 100644
--- a/common/StringUtil.h
+++ b/common/StringUtil.h
@@ -59,6 +59,12 @@
 		return stream.str();
 	}
 
+	static string to_string(float val) {
+		std::stringstream stream;
+		stream << std::fixed << std::setprecision(2) << val;
+		return stream.str();
+	}
+
 	static bool isNumber(const std::string& str) {
 		if (str.empty()) {
 			return false;
@@ -130,4 +136,20 @@
 		return decoded;
 	}
 
+	static std::string trim(const std::string& str) {
+		if (str.empty()) {
+			return str;
+		}
+
+		// 去除前空格
+		size_t start = str.find_first_not_of(" \t\n\r");
+		if (start == std::string::npos) {
+			return ""; // 如果全是空格,返回空字符串
+		}
+
+		// 去除后空格
+		size_t end = str.find_last_not_of(" \t\n\r");
+		return str.substr(start, end - start + 1);
+	}
+
 };
\ No newline at end of file

--
Gitblit v1.8.0