MCPcopy Create free account
hub / github.com/MJx0/KittyMemoryEx / parse

Method parse

KittyMemoryEx/KittyMemoryEx.cpp:129–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127 }
128
129 bool ProcStatus::parse(const std::string &path, ProcStatus *out)
130 {
131 if (out)
132 out->data.clear();
133
134 std::ifstream file(path.c_str());
135 if (!file.is_open())
136 return false;
137
138 std::string line;
139
140 while (std::getline(file, line))
141 {
142 std::size_t colon = line.find(':');
143 if (colon == std::string::npos)
144 continue;
145
146 std::string key = line.substr(0, colon);
147
148 while (!key.empty() && std::isspace(static_cast<unsigned char>(key.back())))
149 key.pop_back();
150
151 const char *p = line.c_str() + colon + 1;
152
153 while (*p && std::isspace(static_cast<unsigned char>(*p)))
154 ++p;
155
156 std::string value(p);
157
158 while (!value.empty() && std::isspace(static_cast<unsigned char>(value.back())))
159 value.pop_back();
160
161 if (out)
162 out->data.emplace(std::move(key), std::string(p));
163 }
164
165 return true;
166 }
167
168 std::vector<ProcMap> getAllMaps(pid_t pid)
169 {

Callers

nothing calls this directly

Calls 1

clearMethod · 0.80

Tested by

no test coverage detected