The Gaudi Framework  v30r3 (a5ef0a68)
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 132 of file SystemWin32.cpp.

133  {
134 
135  static const size_t STRING_SIZE = 512;
136  char uname[STRING_SIZE];
137  size_t strlen = STRING_SIZE;
138  if ( !::GetUserName( uname, &strlen ) ) {
139  return "UNKNOWN";
140  }
141  return std::string( uname );
142  }
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 18 of file SystemWin32.cpp.

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

96  {
97 
98  static const size_t STRING_SIZE = 512;
99  char hname[STRING_SIZE];
100  size_t strlen = STRING_SIZE;
101  if ( !::GetComputerName( hname, &strlen ) ) {
102  return "UNKNOWN";
103  }
104  return std::string( hname );
105  }
STL class.
T strlen(T...args)
std::string System::Win32::machineType ( )

Get the runner machine's type.

Machine type.

Definition at line 122 of file SystemWin32.cpp.

123  {
124 
125  SYSTEM_INFO ut;
126  ::GetSystemInfo( &ut );
127  std::ostringstream arch;
128  arch << ut.wProcessorArchitecture;
129  return arch.str();
130  }
std::string System::Win32::osName ( )

Get the operating system's name.

OS name.

Definition at line 107 of file SystemWin32.cpp.

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

Get the operating system's version.

OS version.

Definition at line 109 of file SystemWin32.cpp.

110  {
111 
112  OSVERSIONINFO ut;
113  ut.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
114  if ( !::GetVersionEx( &ut ) ) {
115  return "UNKNOWN";
116  }
117  std::ostringstream ver;
118  ver << ut.dwMajorVersion << '.' << ut.dwMinorVersion;
119  return ver.str();
120  }
std::string System::Win32::typeinfoName ( const char *  class_name)

Get the human readable type name from a typeinfo name.

Definition at line 54 of file SystemWin32.cpp.

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