The Gaudi Framework  v31r0 (aeb156f0)
System::Win32 Namespace Reference

Namespace holding Windows specific functions. More...

Functions

std::vector< std::stringcmdLineArgs ()
 Get the command line arguments of the process. More...
 
std::string typeinfoName (const char *name)
 Get the human readable type name from a typeinfo name. More...
 
std::string hostName ()
 Get the system's host name. More...
 
std::string osName ()
 Get the operating system's name. More...
 
std::string osVersion ()
 Get the operating system's version. More...
 
std::string machineType ()
 Get the runner machine's type. More...
 
std::string accountName ()
 Get the account name of the current user. More...
 

Detailed Description

Namespace holding Windows specific functions.

Function Documentation

std::string System::Win32::accountName ( )

Get the account name of the current user.

User login name.

Definition at line 113 of file SystemWin32.cpp.

113  {
114 
115  static const size_t STRING_SIZE = 512;
116  char uname[STRING_SIZE];
117  size_t strlen = STRING_SIZE;
118  if ( !::GetUserName( uname, &strlen ) ) { return "UNKNOWN"; }
119  return std::string( uname );
120  }
STL class.
T strlen(T...args)
std::vector< std::string > System::Win32::cmdLineArgs ( )

Get the command line arguments of the process.

Command line arguments including executable name as arg[0] as vector of strings.

Definition at line 16 of file SystemWin32.cpp.

16  {
17 
18  // The result object:
20 
21  // For compatibility with UNIX we CANNOT use strtok!
22  // If we would use strtok, options like -g="My world" at
23  // the command line level would result on NT in TWO options
24  // instead in one as in UNIX.
25  char exe[1024];
26  char *next, *tmp1, *tmp2;
27  for ( LPTSTR cmd = ::GetCommandLine(); *cmd; cmd = next ) {
28  ::memset( exe, 0, sizeof( exe ) );
29  while ( *cmd == ' ' ) cmd++;
30  next = ::strchr( cmd, ' ' );
31  if ( !next ) next = cmd + ::strlen( cmd );
32  if ( ( tmp1 = ::strchr( cmd, '\"' ) ) > 0 && tmp1 < next ) {
33  tmp2 = ::strchr( ++tmp1, '\"' );
34  if ( tmp2 > 0 ) {
35  next = ++tmp2;
36  if ( cmd < tmp1 ) ::strncpy( exe, cmd, tmp1 - cmd - 1 );
37  ::strncpy( &exe[strlen( exe )], tmp1, tmp2 - tmp1 - 1 );
38  } else {
39  std::cout << "Mismatched \" in command line arguments" << std::endl;
40  return std::vector<std::string>();
41  }
42  } else {
43  ::strncpy( exe, cmd, next - cmd );
44  }
45  result.push_back( exe );
46  }
47 
48  return result;
49  }
T endl(T...args)
T push_back(T...args)
T strlen(T...args)
T next(T...args)
T strchr(T...args)
std::string System::Win32::hostName ( )

Get the system's host name.

Host name.

Definition at line 83 of file SystemWin32.cpp.

83  {
84 
85  static const size_t STRING_SIZE = 512;
86  char hname[STRING_SIZE];
87  size_t strlen = STRING_SIZE;
88  if ( !::GetComputerName( hname, &strlen ) ) { return "UNKNOWN"; }
89  return std::string( hname );
90  }
STL class.
T strlen(T...args)
std::string System::Win32::machineType ( )

Get the runner machine's type.

Machine type.

Definition at line 104 of file SystemWin32.cpp.

104  {
105 
106  SYSTEM_INFO ut;
107  ::GetSystemInfo( &ut );
108  std::ostringstream arch;
109  arch << ut.wProcessorArchitecture;
110  return arch.str();
111  }
std::string System::Win32::osName ( )

Get the operating system's name.

OS name.

Definition at line 92 of file SystemWin32.cpp.

92 { return "Windows"; }
std::string System::Win32::osVersion ( )

Get the operating system's version.

OS version.

Definition at line 94 of file SystemWin32.cpp.

94  {
95 
96  OSVERSIONINFO ut;
97  ut.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
98  if ( !::GetVersionEx( &ut ) ) { return "UNKNOWN"; }
100  ver << ut.dwMajorVersion << '.' << ut.dwMinorVersion;
101  return ver.str();
102  }
std::string System::Win32::typeinfoName ( const char *  class_name)

Get the human readable type name from a typeinfo name.

Definition at line 51 of file SystemWin32.cpp.

51  {
52 
53  // The result variable:
54  std::string result;
55 
56  long off = 0;
57  if ( ::strncmp( class_name, "class ", 6 ) == 0 ) {
58  // The returned name is prefixed with "class "
59  off = 6;
60  }
61  if ( ::strncmp( class_name, "struct ", 7 ) == 0 ) {
62  // The returned name is prefixed with "struct "
63  off = 7;
64  }
65  if ( off > 0 ) {
66  std::string tmp = class_name + off;
67  long loc = 0;
68  while ( ( loc = tmp.find( "class " ) ) > 0 ) { tmp.erase( loc, 6 ); }
69  loc = 0;
70  while ( ( loc = tmp.find( "struct " ) ) > 0 ) { tmp.erase( loc, 7 ); }
71  result = tmp;
72  } else {
73  result = class_name;
74  }
75  // Change any " *" to "*"
76  while ( ( off = result.find( " *" ) ) != std::string::npos ) { result.replace( off, 2, "*" ); }
77  // Change any " &" to "&"
78  while ( ( off = result.find( " &" ) ) != std::string::npos ) { result.replace( off, 2, "&" ); }
79 
80  return result;
81  }
STL class.
T replace(T...args)
T erase(T...args)
T find(T...args)
T strncmp(T...args)