~ubuntu-branches/ubuntu/oneiric/libclaw/oneiric

« back to all changes in this revision

Viewing changes to claw/system_info_win32.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Julien Jorge
  • Date: 2008-05-17 15:36:57 UTC
  • Revision ID: james.westby@ubuntu.com-20080517153657-0b1204j754ykoz48
Tags: upstream-1.5.2b
ImportĀ upstreamĀ versionĀ 1.5.2b

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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-2008 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@yahoo.fr
 
24
*/
 
25
/**
 
26
 * \file system_info_win32.hpp
 
27
 * \brief A class to get some informations about the system in which your
 
28
 *        program runs.
 
29
 * \author Julien Jorge
 
30
 */
 
31
#ifndef __CLAW_SYSTEM_INFO_WIN32_HPP__
 
32
#define __CLAW_SYSTEM_INFO_WIN32HPP__
 
33
 
 
34
#include <cstdlib>
 
35
#include <string>
 
36
 
 
37
namespace claw
 
38
{
 
39
  /**
 
40
   * \brief A class to get some informations about the system in which your
 
41
   *        program runs.
 
42
   * \author Julien Jorge
 
43
   */
 
44
  class system_info
 
45
  {
 
46
  public:
 
47
    /*------------------------------------------------------------------------*/
 
48
    /**
 
49
     * \brief Get the name of the user (the name used for the connection).
 
50
     */
 
51
    static std::string get_user_name()
 
52
    {
 
53
      return get_environment("USERNAME");
 
54
    } // get_user_name()
 
55
 
 
56
    /*------------------------------------------------------------------------*/
 
57
    /**
 
58
     * \brief Get the path of the user's personnal directory.
 
59
     */
 
60
    static std::string get_user_directory()
 
61
    {
 
62
      return get_environment("USERPROFILE");
 
63
    } // get_user_directory()
 
64
 
 
65
    /*------------------------------------------------------------------------*/
 
66
    /**
 
67
     * \brief Get system's paths.
 
68
     */
 
69
    template<typename Sequence>
 
70
    static void get_path( Sequence& path )
 
71
    {
 
72
      //
 
73
    } // get_path()
 
74
 
 
75
    /*------------------------------------------------------------------------*/
 
76
    /**
 
77
     * \brief Get the name of our host.
 
78
     */
 
79
    static std::string get_host_name()
 
80
    {
 
81
      return get_environment("COMPUTERNAME");
 
82
    } // get_host_name()
 
83
 
 
84
    /*------------------------------------------------------------------------*/
 
85
    /**
 
86
     * \brief Get the path of the directory used by the system to save temporary
 
87
     *        files.
 
88
     */
 
89
    static std::string get_temporary_directory()
 
90
    {
 
91
      return get_environment("TEMP");
 
92
    } // get_temporary_directory()
 
93
 
 
94
    /*------------------------------------------------------------------------*/
 
95
    /**
 
96
     * \brief Get an environment variable.
 
97
     * \param var The name of the variable to get.
 
98
     */
 
99
    static std::string get_environment( const std::string& var )
 
100
    {
 
101
      char* value = getenv( var.c_str() );
 
102
      std::string result;
 
103
 
 
104
      if ( value )
 
105
        result = value;
 
106
 
 
107
      return result;
 
108
    } // get_environment()
 
109
 
 
110
  }; // class system_info
 
111
} // namespace claw
 
112
 
 
113
#endif // __CLAW_SYSTEM_INFO_WIN32_HPP__