src/linux_parser.cpp
string LinuxParser::Ram(int pid) {
  string name = "VmData";
  string title, value;
  std::ifstream stream(kProcDirectory + to_string(pid) + kStatusFilename);
  string line;
  while (std::getline(stream, line)){
    if(line.compare(0, name.size(), name) == 0){
      std::istringstream linestream(line);
      linestream >> title >> value;
      break;
    }
  }
  if (value == ""){
    return "0";
  }

  value = to_string(stof(value.c_str())/1024);
  return value.substr(0,6); 
}
// TODO: Read and return the memory used by a process
// REMOVE: [[maybe_unused]] once you define the function
Read and return the memory used by a process
REMOVE: [[maybe_unused]] once you define the function
Read and return the memory used by a process REMOVE : [[ maybe_unused ]] once you define the function
string LinuxParser::Ram(int pid) {
  string name = "VmData";
  string title, value;
  std::ifstream stream(kProcDirectory + to_string(pid) + kStatusFilename);
  string line;
  while (std::getline(stream, line)){
    if(line.compare(0, name.size(), name) == 0){
      std::istringstream linestream(line);
      linestream >> title >> value;
      break;
    }
  }
  if (value == ""){
    return "0";
  }
  value = to_string(stof(value.c_str())/1024);
  return value.substr(0,6); 
}
string LinuxParser :: Ram ( int pid ) { string name = " " ; string title , value ; std :: ifstream stream ( kProcDirectory + to_string ( pid ) + kStatusFilename ) ; string line ; while ( std :: getline ( stream , line ) ) { if ( line . compare ( 0 , name . size ( ) , name ) == 0 ) { std :: istringstream linestream ( line ) ; linestream >> title >> value ; break ; } } if ( value == " " ) { return " " ; } value = to_string ( stof ( value . c_str ( ) ) / 1024 ) ; return value . substr ( 0 , 6 ) ; }
TODO: Read and return the memory used by a process
REMOVE: [[maybe_unused]] once you define the function
TODO : Read and return the memory used by a process REMOVE : [[ maybe_unused ]] once you define the function