WSL/SLF GitLab Repository

Commit d77be9e1 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Fixed some broken examples and added a getHostName() function in IOUtils

parent 0c31c352
......@@ -29,7 +29,7 @@ int main() {
//A nice finishing touch: we print nicely formatted lat/lon
cout << "Pretty printing\n";
cout << "\t(" << point1.getLat() << " , " << point1.getLon() << ") = " << point1.printLatLon() << endl;
cout << "\t(" << point1.getLat() << " , " << point1.getLon() << ") = " << point1.toString(Coords::LATLON) << endl;
return 0;
}
......@@ -29,7 +29,7 @@ int main(void) {
Coords point("CH1903", "");
point.setXY(559500., 221500., 1050.);
grid1.gridify(point); //computes the point position (i,j) in the grid
std::cout << "Position " << point.printLatLon() << " is point (" << point.getGridI() << "," << point.getGridJ() << ") in the grid with elevation=" << grid1.grid2D(point.getGridI(), point.getGridJ()) << "\n";
std::cout << "Position " << point.toString(Coords::LATLON) << " is point (" << point.getGridI() << "," << point.getGridJ() << ") in the grid with elevation=" << grid1.grid2D(point.getGridI(), point.getGridJ()) << "\n";
//now let's make a grid subset: from point (2,2) and size 5x5
Grid2DObject subgrid(grid1, 2, 2, 5, 5);
......
......@@ -19,6 +19,7 @@
#include <cstring>
#include <ctype.h>
#include <algorithm>
#include <unistd.h>
#include <meteoio/IOUtils.h>
#include <meteoio/MathOptim.h>
......@@ -216,6 +217,18 @@ std::string getLogName() {
return std::string(tmp);
}
std::string getHostName() {
const size_t len = 128;
char name[len];
if (gethostname(name, len) != 0) {
return std::string("N/A");
}
if (name[0] == '\0') return std::string("N/A");
return std::string(name);
}
void readKeyValueHeader(std::map<std::string,std::string>& headermap,
std::istream& fin, const size_t& linecount,
const std::string& delimiter, const bool& keep_case)
......
......@@ -113,6 +113,12 @@ namespace IOUtils {
* @return user name
*/
std::string getLogName();
/**
* @brief Retrieve the name of the computer running the binary
* @return host name
*/
std::string getHostName();
/**
* @brief Removes trailing and leading whitespaces, tabs and newlines from a string.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment