admin
2025-04-08 5c9991be21f57781573f04961ec511ac2938ea3d
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);
   }
};