1 #ifndef _UTIL_HPP_ 2 #define _UTIL_HPP_ 3 4 #include <string> 5 #include <string_view> 6 7 namespace metric_blob 8 { 9 10 struct TcommUtimeStime 11 { 12 std::string tcomm; 13 float utime; 14 float stime; 15 }; 16 17 TcommUtimeStime parseTcommUtimeStimeString(std::string_view content, 18 long ticksPerSec); 19 std::string readFileIntoString(std::string_view fileName); 20 bool isNumericPath(std::string_view path, int& value); 21 TcommUtimeStime getTcommUtimeStime(int pid, long ticksPerSec); 22 std::string getCmdLine(int pid); 23 bool parseMeminfoValue(std::string_view content, std::string_view keyword, 24 int& value); 25 bool parseProcUptime(const std::string_view content, double& uptime, 26 double& idleProcessTime); 27 long getTicksPerSec(); 28 char controlCharsToSpace(char c); 29 std::string trimStringRight(std::string_view s); 30 31 } // namespace metric_blob 32 33 #endif