--- nono/lib/mystring.h 2026/04/29 17:04:57 1.1.1.5 +++ nono/lib/mystring.h 2026/04/29 17:05:47 1.1.1.8 @@ -4,6 +4,10 @@ // Licensed under nono-license.txt // +// +// 文字列操作 +// + #pragma once #include "header.h" @@ -23,8 +27,9 @@ extern void rtrim(char *str); // 文字列 str から先頭と末尾の連続する空白文字を取り除いた新しい文字列を返す。 extern std::string string_trim(const std::string& str); -// 文字列中の ASCII 大文字を小文字にした新しい文字列を返す +// 文字列中の ASCII 大文字を小文字に、小文字を大文字にした新しい文字列を返す。 extern std::string string_tolower(const std::string& str); +extern std::string string_toupper(const std::string& str); // 文字列 lhs の先頭が rhs と大文字小文字の区別なしで一致すれば true を返す。 // ASCII 専用。 @@ -52,3 +57,14 @@ static inline std::vector s char c, int nlimit = 0) { return string_split(str.c_str(), str.size(), c, nlimit); } + +// val を3桁ずつカンマ区切りした文字列にして返す。 +extern std::string format_number(uint64 val); + +// val を width 桁ゼロ埋めした 16進数文字列にして返す。 +extern std::string strhex(uint32 val, int width = 8); + +// 経過時刻 t を文字列にして返す。(フル版) +extern const std::string TimeToStr(uint64 t); +// 経過時刻 t を文字列にして返す。(10秒未満のみの短縮版) +extern const std::string SecToStr(uint64 t);