claw 1.9.0
 
Loading...
Searching...
No Matches
system_info_win32.hpp
Go to the documentation of this file.
1/*
2 CLAW - a C++ Library Absolutely Wonderful
3
4 CLAW is a free library without any particular aim but being useful to
5 anyone.
6
7 Copyright (C) 2005-2011 Julien Jorge
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
23 contact: julien.jorge@stuff-o-matic.com
24*/
31#ifndef __CLAW_SYSTEM_INFO_WIN32_HPP__
32#define __CLAW_SYSTEM_INFO_WIN32HPP__
33
34#include <cstdlib>
35#include <string>
36
37namespace claw
38{
44 class system_info
45 {
46 public:
50 static std::string get_user_name()
51 {
52 return get_environment("USERNAME");
53 }
54
58 static std::string get_user_directory()
59 {
60 return get_environment("USERPROFILE");
61 }
62
66 template <typename Sequence>
67 static void get_path(Sequence& path)
68 {
69 //
70 }
71
75 static std::string get_host_name()
76 {
77 return get_environment("COMPUTERNAME");
78 }
79
84 static std::string get_temporary_directory()
85 {
86 return get_environment("TEMP");
87 }
88
93 static std::string get_environment(const std::string& var)
94 {
95 char* value = getenv(var.c_str());
96 std::string result;
97
98 if(value)
99 result = value;
100
101 return result;
102 }
103
104 }; // class system_info
105}
106
107#endif // __CLAW_SYSTEM_INFO_WIN32_HPP__
A class to get some informations about the system in which your program runs.
static void get_path(Sequence &path)
Get system's paths.
static std::string get_host_name()
Get the name of our host.
static std::string get_user_directory()
Get the path of the user's personnal directory.
static std::string get_user_name()
Get the name of the user (the name used for the connection).
static std::string get_environment(const std::string &var)
Get an environment variable.
static std::string get_temporary_directory()
Get the path of the directory used by the system to save temporary files.
This is the main namespace.