system_info_unix.hpp
Go to the documentation of this file.
/*
CLAW - a C++ Library Absolutely Wonderful
CLAW is a free library without any particular aim but being useful to
anyone.
Copyright (C) 2005-2011 Julien Jorge
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
contact: julien.jorge@gamned.org
*/
#ifndef __CLAW_SYSTEM_INFO_UNIX_HPP__
#define __CLAW_SYSTEM_INFO_UNIXHPP__
#include <cstdlib>
#include <string>
namespace claw
{
class system_info
{
public:
/*------------------------------------------------------------------------*/
static std::string get_user_name()
{
std::string result( get_environment("USER") );
if ( result.empty() )
result = get_environment("LOGNAME");
return result;
} // get_user_name()
/*------------------------------------------------------------------------*/
static std::string get_user_directory()
{
return get_environment("HOME");
} // get_user_directory()
/*------------------------------------------------------------------------*/
template<typename Sequence>
static void get_path( Sequence& path )
{
//
} // get_path()
/*------------------------------------------------------------------------*/
static std::string get_host_name()
{
return get_environment("HOSTNAME");
} // get_host_name()
/*------------------------------------------------------------------------*/
static std::string get_temporary_directory()
{
return get_environment("TMPDIR");
} // get_temporary_directory()
/*------------------------------------------------------------------------*/
static std::string get_environment( const std::string& var )
{
char* value = getenv( var.c_str() );
std::string result;
if ( value )
result = value;
return result;
} // get_environment()
}; // class system_info
} // namespace claw
#endif // __CLAW_SYSTEM_INFO_UNIX_HPP__
claw::system_info
A class to get some informations about the system in which your program runs.
Definition: system_info_unix.hpp:44
claw::system_info::get_path
static void get_path(Sequence &path)
Get system&#39;s paths.
Definition: system_info_unix.hpp:75
claw::system_info::get_user_name
static std::string get_user_name()
Get the name of the user (the name used for the connection).
Definition: system_info_unix.hpp:51
claw::system_info::get_host_name
static std::string get_host_name()
Get the name of out host.
Definition: system_info_unix.hpp:84
claw::system_info::get_user_directory
static std::string get_user_directory()
Get the path of the user&#39;s personnal directory.
Definition: system_info_unix.hpp:65
claw::system_info::get_temporary_directory
static std::string get_temporary_directory()
Get the path of the directory used by the system to save temporary files.
Definition: system_info_unix.hpp:94
claw
This is the main namespace.
Definition: algorithm.hpp:33
claw::system_info::get_environment
static std::string get_environment(const std::string &var)
Get an environment variable.
Definition: system_info_unix.hpp:104