Reflex C++

Reflex::System

The System module abstracts all platform-specific functionality — time, filesystem, input, networking, windowing, and rendering. You typically use it indirectly through higher-level modules, but it's available for low-level control.

Platform Utilities

The System module abstracts all platform-specific functionality. You typically use it indirectly through higher-level modules (GLX, File), but it's available for low-level control.

Time

Float64 GetElapsedTime(); // High-resolution elapsed time (seconds)
UInt64 GetTime(); // System time

System Info

UInt32 GetNumProcessor(); // CPU core count
CString GetOperatingSystemVersion(); // e.g. "Windows 10.0.19045"
UInt64 GetSystemID(); // Unique machine identifier

Paths

WString GetPath(Path path_id); // Get system path

Path Constants

ConstantDescription
kPathTempTemp directory
kPathDesktopUser desktop
kPathApplicationDataApp data (roaming)
kPathUserDataUser data directory
kPathUserDocumentsUser documents

Filesystem

bool Exists(const WString& path);
bool IsDirectory(const WString& path);
bool MakeDirectory(const WString& path);
bool Rename(const WString& from, const WString& to);
bool Delete(const WString& path);
bool Launch(const WString& path); // Open file/URL with default handler

Enumerations

System-level enumerations for input handling, cursors, and HTTP responses.

MouseCursor

ConstantDescription
kMouseCursorInvisibleHidden cursor
kMouseCursorArrowDefault arrow
kMouseCursorWaitHourglass / spinner
kMouseCursorMoveFour-way move
kMouseCursorLeftRightHorizontal resize
kMouseCursorTopBottomVertical resize
kMouseCursorTopLeftBottomRightDiagonal resize (↘)
kMouseCursorBottomLeftTopRightDiagonal resize (↗)
kMouseCursorPointerHand / link
kMouseCursorDragDrag handle
kMouseCursorTextI-beam
kMouseCursorBlockNot-allowed
kMouseCursorZoomMagnifying glass

KeyCode

kKeyCodeNull, kKeyCodeF1 ... kKeyCodeF12
kKeyCodeTab, kKeyCodeEnter, kKeyCodeEscape, kKeyCodeSpace
kKeyCodeBackspace, kKeyCodeInsert, kKeyCodeDelete
kKeyCodeHome, kKeyCodeEnd, kKeyCodePageUp, kKeyCodePageDown
kKeyCodeUp, kKeyCodeDown, kKeyCodeLeft, kKeyCodeRight
kKeyCode0 ... kKeyCode9, kKeyCodeA ... kKeyCodeZ
kKeyCodeMinus, kKeyCodePlus, kKeyCodeSlash
kKeyCodeBracketOpen, kKeyCodeBracketClose
kKeyCodeNumericDivide/Multiply/Minus/Plus

ModifierKeys

ConstantDescription
kModifierKeyShiftShift key
kModifierKeyCtrlControl key
kModifierKeyAltAlt / Option key
kModifierKeySystemCmd on macOS, Win on Windows

HttpConnection::Response

ConstantDescription
kResponseAbortedRequest was aborted
kResponseNoConnectionNo connection available
kResponseOK200 OK
kResponsePartialContent206 Partial Content
kResponseMovedPermanently301 Moved Permanently
kResponseFound302 Found
kResponseBadRequest400 Bad Request
kResponseUnauthorized401 Unauthorized
kResponseForbidden403 Forbidden
kResponseNotFound404 Not Found
kResponseInternalServerError500 Internal Server Error
kResponseServiceUnavailable503 Service Unavailable

Type Aliases

Convenience aliases for commonly used parameterised types, plus the Colour type.

Geometry Aliases

AliasExpands To
fPointPoint<Float32>
fSizeSize<Float32>
fRectRect<Float32>
ColourPointTuple<Point<Float32>, Colour>

Colour

All colour components are 0.0–1.0 floating point.

Float32 Colour::r;
Float32 Colour::g;
Float32 Colour::b;
Float32 Colour::a;

System Classes

Low-level system classes that all inherit from Object. These handle file I/O, networking, windowing, rendering, threading, and more.

Overview

ClassInheritsPurpose
FileHandleObjectLow-level file I/O handle
HttpConnectionObjectHTTP client
WindowObjectNative window
RendererObjectGPU renderer
Renderer::CanvasObjectDrawing surface
Renderer::GraphicObjectRenderable graphic
ThreadTaskOS thread
ProcessThreadChild process
TaskObjectBase for async operations
DirectoryIteratorObjectEnumerate directory contents
DiskIteratorObjectEnumerate disk volumes
DynamicLibraryObjectLoad shared libraries (.dll/.dylib/.so)

FileHandle

Low-level file I/O. Most applications will use higher-level file utilities, but FileHandle is available when you need direct control.

bool FileHandle::Status(); // Is handle valid?
bool FileHandle::IsWriteable();
UInt64 FileHandle::GetSize();
void FileHandle::SetPosition(UInt64 position);
UInt64 FileHandle::GetPosition();
UInt32 FileHandle::Read(void* bytes, UInt32 buffer_capacity);
UInt32 FileHandle::Write(const void* bytes, UInt32 size);

HttpConnection

HTTP client for making network requests.

void HttpConnection::SetTimeout(Float32 connection, Float32 transfer);
HttpConnection::Response HttpConnection::Request(
const CString::View& method,
const CString::View& resource,
const ArrayView<Pair<Array<char>, Array<char>>>& headers,
const ArrayView<UInt8>& body,
const HttpConnection::ReceiveHeaderFn& receive_header,
const HttpConnection::ReceiveDataFn& receive_data
);