CppND-System-Monitor/src/linux_parser.cpp
string LinuxParser::GetValueFromProcStat(string keyToFind) {
  string key, value, line;
  std::ifstream stream(kProcDirectory + kStatFilename);
  if (stream.is_open()) {
    while (std::getline(stream, line)) {
      std::istringstream linestream(line);
      linestream >> key >> value;
      if (key == keyToFind) {
        return value;
      }
    }
  }
  return value;
}
// Read /proc/stat file and return value corresponding to key
Read /proc/stat file and return value corresponding to key
Read / proc / stat file and return value corresponding to key
string LinuxParser::GetValueFromProcStat(string keyToFind) {
  string key, value, line;
  std::ifstream stream(kProcDirectory + kStatFilename);
  if (stream.is_open()) {
    while (std::getline(stream, line)) {
      std::istringstream linestream(line);
      linestream >> key >> value;
      if (key == keyToFind) {
        return value;
      }
    }
  }
  return value;
}
string LinuxParser :: GetValueFromProcStat ( string keyToFind ) { string key , value , line ; std :: ifstream stream ( kProcDirectory + kStatFilename ) ; if ( stream . is_open ( ) ) { while ( std :: getline ( stream , line ) ) { std :: istringstream linestream ( line ) ; linestream >> key >> value ; if ( key == keyToFind ) { return value ; } } } return value ; }
Read /proc/stat file and return value corresponding to key
Read / proc / stat file and return value corresponding to key