ReXGlue SDK
Loading...
Searching...
No Matches
process.h
Go to the documentation of this file.
1
15
16#pragma once
17
18#include <cstdio>
19#include <filesystem>
20#include <memory>
21#include <optional>
22#include <span>
23#include <string>
24#include <string_view>
25#include <utility>
26#include <vector>
27
28#include <rex/platform.h>
29#include <rex/result.h>
30#include <rex/types.h>
31#include <rex/utility.h>
32
33namespace rex::platform {
34
35namespace detail {
36struct LockHandle;
37
45REX_API std::wstring BuildCommandLine(std::wstring_view exe, std::span<const std::string> args);
46} // namespace detail
47
49class REX_API InstanceLock : public MoveOnly {
50 public:
51 InstanceLock(InstanceLock&& other) noexcept;
52 InstanceLock& operator=(InstanceLock&& other) noexcept;
53 ~InstanceLock();
54
61 [[nodiscard]] static Result<InstanceLock> Acquire(std::string_view name);
62
63 private:
64 explicit InstanceLock(std::unique_ptr<detail::LockHandle> handle);
65 std::unique_ptr<detail::LockHandle> handle_;
66};
67
73[[nodiscard]] REX_API Result<void> Relaunch(std::span<const std::string> args);
74
82[[nodiscard]] REX_API Result<void> Relaunch(const std::filesystem::path& exe,
83 std::span<const std::string> args,
84 const std::filesystem::path& working_directory = {});
85
88
90 u64 before = 0;
91 u64 after = 0;
92 u64 hard = 0;
93};
94
102
108[[nodiscard]] REX_API std::string DescribeResourceUse();
109
110} // namespace rex::platform
111
112namespace rex::platform {
113
119REX_API bool IsTerminal(FILE* stream);
120
127REX_API bool EnableANSIEscapes(FILE* stream);
128
131
132} // namespace rex::platform
133
134namespace rex::platform {
135
138
141
142} // namespace rex::platform
143
144namespace rex::platform {
145
152REX_API std::optional<std::string> GetEnvironmentValue(std::string_view name);
153
160REX_API bool SetEnvironmentValue(std::string_view name, std::string_view value);
161
168REX_API bool UnsetEnvironmentValue(std::string_view name);
169
175REX_API std::vector<std::pair<std::string, std::string>> EnumerateEnvironment();
176
177} // namespace rex::platform
178
179namespace rex {
180
182enum class MessageType : u8 {
183 kInfo,
184 kWarning,
185 kError,
186};
187
194REX_API void ShowMessageBox(MessageType type, std::string_view message);
195
196} // namespace rex
197
198namespace rex::platform {
199
202 // NOLINTNEXTLINE(readability-redundant-member-init): designated initializers omit this field
203 std::string app_name = {};
204 bool show_dialog = false;
205};
206
215using CrashAddressDescriber = u32 (*)(u64 host_address, std::span<char> out);
216
223
226
233
236
237} // namespace rex::platform
static Result< InstanceLock > Acquire(std::string_view name)
Definition platform.h:345
bool UnsetEnvironmentValue(std::string_view name)
bool IsTerminal(FILE *stream)
bool CanRelaunch()
Result< void > Relaunch(std::span< const std::string > args)
std::optional< std::string > GetEnvironmentValue(std::string_view name)
bool IsDebuggerAttached()
void SetUTF8OutputCodePage()
void SetCrashAddressDescriber(CrashAddressDescriber describer)
void PrepareThreadForCrash()
std::vector< std::pair< std::string, std::string > > EnumerateEnvironment()
bool EnableANSIEscapes(FILE *stream)
void UninstallCrashReporter()
bool SetEnvironmentValue(std::string_view name, std::string_view value)
std::string DescribeResourceUse()
u32(*)(u64 host_address, std::span< char > out) CrashAddressDescriber
Definition process.h:215
Result< OpenFileLimit > RaiseOpenFileLimit()
Result< void > InstallCrashReporter(const CrashReporterOptions &options)
Definition app.h:36
void ShowMessageBox(MessageType type, std::string_view message)
std::expected< T, Error > Result
Definition result.h:98
MessageType
Definition process.h:182
Platform flags, packing macros and export markers.
#define REX_API
Definition platform.h:177
Definition process.h:200
std::string app_name
Definition process.h:203
Definition process.h:89
u64 hard
Definition process.h:92
u64 before
Definition process.h:90
u64 after
Definition process.h:91
Integer types, byte order wrappers and size literals.
Move only function, const propagating pointer and scope guard.