CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
environment.h
1
3// may be defened in WinBase.h
4#ifdef GetEnvironmentVariable
5//#pragma message("!!! GetEnvironmentVariable defined, please do not include windows.h manually")
6#undef GetEnvironmentVariable
7#undef SetEnvironmentVariable
8#undef GetCurrentDirectory
9#undef SetCurrentDirectory
10#endif
11
12#ifndef _environment_h_
13#define _environment_h_
14
15#include "system/string.h"
16#include "system/exceptions.h"
17#include "system/version.h"
18#include "system/array.h"
19#include "system/operating_system.h"
20#include "system/collections/dictionary.h"
21
22// may be defened in WinBase.h
23#ifdef GetEnvironmentVariable
24//#pragma message("!!! GetEnvironmentVariable defined, please do not include windows.h manually")
25#undef GetEnvironmentVariable
26#undef SetEnvironmentVariable
27#undef GetCurrentDirectory
28#undef SetCurrentDirectory
29#endif
30
31namespace System
32{
35 {
39 User = 1,
42 };
43
48 {
50 enum class SpecialFolder
51 {
53 Desktop = 0,
55 Programs = 2,
57 Personal = 5,
59 MyDocuments = 5,
61 Favorites = 6,
63 Startup = 7,
65 Recent = 8,
67 SendTo = 9,
69 StartMenu = 11,
71 MyMusic = 13,
73 DesktopDirectory = 16,
75 MyComputer = 17,
77 Templates = 21,
79 ApplicationData = 26,
81 LocalApplicationData = 28,
83 InternetCache = 32,
85 Cookies = 33,
87 History = 34,
89 CommonApplicationData = 35,
91 System = 37,
93 ProgramFiles = 38,
95 MyPictures = 39,
97 UserProfile = 40,
99 CommonProgramFiles = 43,
100 };
101
103 static ASPOSECPP_SHARED_API String get_CommandLine();
105 static ASPOSECPP_SHARED_API String get_CurrentDirectory(); // +
108 static ASPOSECPP_SHARED_API void set_CurrentDirectory(const String& path); // +
110 static ASPOSECPP_SHARED_API int get_ExitCode();
113 static ASPOSECPP_SHARED_API void set_ExitCode(int value);
116 static ASPOSECPP_SHARED_API bool get_HasShutdownStarted();
118 static ASPOSECPP_SHARED_API String get_MachineName();
120 static ASPOSECPP_SHARED_API String get_NewLine();
122 static ASPOSECPP_SHARED_API const OperatingSystem& get_OSVersion();
124 static ASPOSECPP_SHARED_API int get_ProcessorCount();
126 static ASPOSECPP_SHARED_API String get_StackTrace();
128 static ASPOSECPP_SHARED_API String get_SystemDirectory();
130 static ASPOSECPP_SHARED_API int get_TickCount();
132 static ASPOSECPP_SHARED_API String get_UserDomainName();
135 static ASPOSECPP_SHARED_API bool get_UserInteractive();
137 static ASPOSECPP_SHARED_API String get_UserName();
140 static ASPOSECPP_SHARED_API Version get_Version();
142 static ASPOSECPP_SHARED_API int64_t get_WorkingSet();
143
146 static ASPOSECPP_SHARED_API void Exit(int exitCode);
150 static ASPOSECPP_SHARED_API String ExpandEnvironmentVariables(const String& name);
153 static ASPOSECPP_SHARED_API void FailFast(const String& message);
155 static ASPOSECPP_SHARED_API ArrayPtr<String> GetCommandLineArgs();
159 static ASPOSECPP_SHARED_API String GetEnvironmentVariable(const String& variable);
163 static String GetEnvironmentVariableA(const String& variable) { return GetEnvironmentVariable(variable); }
167 static String GetEnvironmentVariableW(const String& variable) { return GetEnvironmentVariable(variable); }
172 static ASPOSECPP_SHARED_API String GetEnvironmentVariable(const String& variable, EnvironmentVariableTarget target);
182 static ASPOSECPP_SHARED_API String GetFolderPath(SpecialFolder folder);
184 static ASPOSECPP_SHARED_API ArrayPtr<String> GetLogicalDrives();
186 static ASPOSECPP_SHARED_API void SetEnvironmentVariable(const String& variable, const String& value);
188 static ASPOSECPP_SHARED_API void SetEnvironmentVariable(const String& variable, const String& value,
191 static ASPOSECPP_SHARED_API bool IsWindowsSubsystemForLinux();
193 static ASPOSECPP_SHARED_API bool get_Is64BitProcess();
194 };
195}
196#endif // _environment_h_
Dictionary pointer class with operator overloads. This type is a pointer to manage other object's del...
Definition: dictionary.h:28
Represents a particular operating system and provides information about it. Objects of this class sho...
Definition: operating_system.h:15
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
Represents a version number. This type should be allocated on stack and passed to functions by value ...
Definition: version.h:15
Definition: db_command.h:9
EnvironmentVariableTarget
Specifies the environment variable location.
Definition: environment.h:35
@ Process
Environment block associated with the current process.
Definition: environment.h:37
@ User
Registry key HKEY_CURRENT_USER\Environment.
Definition: environment.h:39
@ Machine
Registry key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment.
Definition: environment.h:41
Environment services. This is a static type with no instance services. You should never create instan...
Definition: environment.h:48
static ArrayPtr< String > GetLogicalDrives()
Returns an array containing the names of all logical drives on the current computer.
static String get_CommandLine()
Returns the command line used to start the current process.
static bool IsWindowsSubsystemForLinux()
Returns true only for WSL.
static String ExpandEnvironmentVariables(const String &name)
Replaces the names of environment variables found in the specified string with the values of those va...
static String GetEnvironmentVariable(const String &variable, EnvironmentVariableTarget target)
Returns the value of the specified environment varibale from the specified location.
static void SetEnvironmentVariable(const String &variable, const String &value, EnvironmentVariableTarget target)
NOT IMPLEMENTED.
static String GetEnvironmentVariableW(const String &variable)
Returns the value of the specified environment varibale associated with the current process.
Definition: environment.h:167
static String GetEnvironmentVariable(const String &variable)
Returns the value of the specified environment varibale associated with the current process.
static String get_MachineName()
Returns the NetBIOS name of this computer.
static int get_TickCount()
Returns the number of milliseconds passed since the system started.
static String get_StackTrace()
Returns the string that contains the current stack trace inofrmation.
static String get_SystemDirectory()
Returns the path to the system directory.
static void SetEnvironmentVariable(const String &variable, const String &value)
NOT IMPLEMENTED.
static Version get_Version()
Returns the Version object that represents the information about the version of the common language r...
static void Exit(int exitCode)
Terminates the current process and returns the specified exit code to the operating system.
static void FailFast(const String &message)
Aborts the current process.
static String get_CurrentDirectory()
Returns the path to the current working directory.
static Collections::Generic::DictionaryPtr< String, String > GetEnvironmentVariables()
Returns a dictionary containing all environment variables names and their values associated with the ...
static const OperatingSystem & get_OSVersion()
Returns the OperatingSystem object that contains information about the current operating system.
SpecialFolder
Represents system special folders.
Definition: environment.h:51
static int get_ExitCode()
Returns the exit code for the current process.
static bool get_UserInteractive()
Determines whether the current process is running in user interactive mode.
static void set_ExitCode(int value)
Sets the specified value as exit code for the current process.
static void set_CurrentDirectory(const String &path)
Sets the specified directory as the current working directory.
static String get_NewLine()
Returns the newline string set for the current environment.
static bool get_Is64BitProcess()
Returns true for 64-bit platform executables/libs.
static ArrayPtr< String > GetCommandLineArgs()
Returns an array containing the command-line arguments used to start the current process.
static String get_UserDomainName()
Returns the network domain name of the current user.
static String get_UserName()
Returns the name of the user currently logged on to the Windows OS.
static int get_ProcessorCount()
Returns the number of processors or the current machine.
static String GetFolderPath(SpecialFolder folder)
Returns fully qualified path to the specified system folder.
static int64_t get_WorkingSet()
Returns the amount of physical memory mapped to the process context.
static String GetEnvironmentVariableA(const String &variable)
Returns the value of the specified environment varibale associated with the current process.
Definition: environment.h:163
static bool get_HasShutdownStarted()
Checks if shutdown is in progress. Not implemented.
static Collections::Generic::DictionaryPtr< String, String > GetEnvironmentVariables(EnvironmentVariableTarget target)
Returns a dictionary containing all environment variables' names and their values from the specified ...