mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-04 19:25:51 +00:00
Use namespaces instead of static-only classes
This commit is contained in:
committed by
Vinnie Falco
parent
45b5c4ba7a
commit
dbd993ed2b
@@ -33,62 +33,61 @@ namespace beast
|
||||
Contains some static helper functions for manipulating the MS Windows registry
|
||||
(Only available on Windows, of course!)
|
||||
*/
|
||||
class WindowsRegistry
|
||||
namespace WindowsRegistry
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
/** Returns a string from the registry.
|
||||
The path is a string for the entire path of a value in the registry,
|
||||
e.g. "HKEY_CURRENT_USER\Software\foo\bar"
|
||||
*/
|
||||
static String getValue (const String& regValuePath,
|
||||
const String& defaultValue = String::empty);
|
||||
String getValue (const String& regValuePath,
|
||||
const String& defaultValue = String::empty);
|
||||
|
||||
/** Returns a string from the WOW64 registry.
|
||||
The path is a string for the entire path of a value in the registry,
|
||||
e.g. "HKEY_CURRENT_USER\Software\foo\bar"
|
||||
*/
|
||||
static String getValueWow64 (const String& regValuePath,
|
||||
const String& defaultValue = String::empty);
|
||||
String getValueWow64 (const String& regValuePath,
|
||||
const String& defaultValue = String::empty);
|
||||
|
||||
/** Reads a binary block from the registry.
|
||||
The path is a string for the entire path of a value in the registry,
|
||||
e.g. "HKEY_CURRENT_USER\Software\foo\bar"
|
||||
@returns a DWORD indicating the type of the key.
|
||||
*/
|
||||
static std::uint32_t getBinaryValue (const String& regValuePath, MemoryBlock& resultData);
|
||||
std::uint32_t getBinaryValue (const String& regValuePath, MemoryBlock& resultData);
|
||||
|
||||
/** Sets a registry value as a string.
|
||||
This will take care of creating any groups needed to get to the given registry value.
|
||||
*/
|
||||
static bool setValue (const String& regValuePath, const String& value);
|
||||
bool setValue (const String& regValuePath, const String& value);
|
||||
|
||||
/** Sets a registry value as a DWORD.
|
||||
This will take care of creating any groups needed to get to the given registry value.
|
||||
*/
|
||||
static bool setValue (const String& regValuePath, std::uint32_t value);
|
||||
bool setValue (const String& regValuePath, std::uint32_t value);
|
||||
|
||||
/** Sets a registry value as a QWORD.
|
||||
This will take care of creating any groups needed to get to the given registry value.
|
||||
*/
|
||||
static bool setValue (const String& regValuePath, std::uint64_t value);
|
||||
bool setValue (const String& regValuePath, std::uint64_t value);
|
||||
|
||||
/** Sets a registry value as a binary block.
|
||||
This will take care of creating any groups needed to get to the given registry value.
|
||||
*/
|
||||
static bool setValue (const String& regValuePath, const MemoryBlock& value);
|
||||
bool setValue (const String& regValuePath, const MemoryBlock& value);
|
||||
|
||||
/** Returns true if the given value exists in the registry. */
|
||||
static bool valueExists (const String& regValuePath);
|
||||
bool valueExists (const String& regValuePath);
|
||||
|
||||
/** Returns true if the given value exists in the registry. */
|
||||
static bool valueExistsWow64 (const String& regValuePath);
|
||||
bool valueExistsWow64 (const String& regValuePath);
|
||||
|
||||
/** Deletes a registry value. */
|
||||
static void deleteValue (const String& regValuePath);
|
||||
void deleteValue (const String& regValuePath);
|
||||
|
||||
/** Deletes a registry key (which is registry-talk for 'folder'). */
|
||||
static void deleteKey (const String& regKeyPath);
|
||||
void deleteKey (const String& regKeyPath);
|
||||
|
||||
/** Creates a file association in the registry.
|
||||
|
||||
@@ -106,16 +105,12 @@ public:
|
||||
unless running in an installer). If true, it will register the
|
||||
association in HKEY_CURRENT_USER.
|
||||
*/
|
||||
static bool registerFileAssociation (const String& fileExtension,
|
||||
const String& symbolicDescription,
|
||||
const String& fullDescription,
|
||||
const File& targetExecutable,
|
||||
int iconResourceNumber,
|
||||
bool registerForCurrentUserOnly);
|
||||
|
||||
WindowsRegistry() = delete;
|
||||
WindowsRegistry(WindowsRegistry const&) = delete;
|
||||
WindowsRegistry const& operator= (WindowsRegistry const&) = delete;
|
||||
bool registerFileAssociation (const String& fileExtension,
|
||||
const String& symbolicDescription,
|
||||
const String& fullDescription,
|
||||
const File& targetExecutable,
|
||||
int iconResourceNumber,
|
||||
bool registerForCurrentUserOnly);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -38,7 +38,7 @@ class MemoryBlock;
|
||||
@see OutputStream, FileInputStream
|
||||
*/
|
||||
class InputStream
|
||||
, LeakChecked <InputStream>
|
||||
: LeakChecked <InputStream>
|
||||
{
|
||||
public:
|
||||
/** Destructor. */
|
||||
|
||||
@@ -31,14 +31,13 @@ namespace beast
|
||||
/**
|
||||
Contains methods for finding out about the current hardware and OS configuration.
|
||||
*/
|
||||
class SystemStats
|
||||
namespace SystemStats
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
/** Returns the current version of BEAST,
|
||||
See also the BEAST_VERSION, BEAST_MAJOR_VERSION and BEAST_MINOR_VERSION macros.
|
||||
*/
|
||||
static String getBeastVersion();
|
||||
String getBeastVersion();
|
||||
|
||||
//==============================================================================
|
||||
/** The set of possible results of the getOperatingSystemType() method. */
|
||||
@@ -73,95 +72,95 @@ public:
|
||||
@returns one of the values from the OperatingSystemType enum.
|
||||
@see getOperatingSystemName
|
||||
*/
|
||||
static OperatingSystemType getOperatingSystemType();
|
||||
OperatingSystemType getOperatingSystemType();
|
||||
|
||||
/** Returns the name of the type of operating system we're running on.
|
||||
|
||||
@returns a string describing the OS type.
|
||||
@see getOperatingSystemType
|
||||
*/
|
||||
static String getOperatingSystemName();
|
||||
String getOperatingSystemName();
|
||||
|
||||
/** Returns true if the OS is 64-bit, or false for a 32-bit OS.
|
||||
*/
|
||||
static bool isOperatingSystem64Bit();
|
||||
bool isOperatingSystem64Bit();
|
||||
|
||||
/** Returns an environment variable.
|
||||
If the named value isn't set, this will return the defaultValue string instead.
|
||||
*/
|
||||
static String getEnvironmentVariable (const String& name, const String& defaultValue);
|
||||
String getEnvironmentVariable (const String& name, const String& defaultValue);
|
||||
|
||||
//==============================================================================
|
||||
/** Returns the current user's name, if available.
|
||||
@see getFullUserName()
|
||||
*/
|
||||
static String getLogonName();
|
||||
String getLogonName();
|
||||
|
||||
/** Returns the current user's full name, if available.
|
||||
On some OSes, this may just return the same value as getLogonName().
|
||||
@see getLogonName()
|
||||
*/
|
||||
static String getFullUserName();
|
||||
String getFullUserName();
|
||||
|
||||
/** Returns the host-name of the computer. */
|
||||
static String getComputerName();
|
||||
String getComputerName();
|
||||
|
||||
/** Returns the language of the user's locale.
|
||||
The return value is a 2 or 3 letter language code (ISO 639-1 or ISO 639-2)
|
||||
*/
|
||||
static String getUserLanguage();
|
||||
String getUserLanguage();
|
||||
|
||||
/** Returns the region of the user's locale.
|
||||
The return value is a 2 letter country code (ISO 3166-1 alpha-2).
|
||||
*/
|
||||
static String getUserRegion();
|
||||
String getUserRegion();
|
||||
|
||||
/** Returns the user's display language.
|
||||
The return value is a 2 or 3 letter language code (ISO 639-1 or ISO 639-2)
|
||||
*/
|
||||
static String getDisplayLanguage();
|
||||
String getDisplayLanguage();
|
||||
|
||||
//==============================================================================
|
||||
// CPU and memory information..
|
||||
|
||||
/** Returns the number of CPU cores. */
|
||||
static int getNumCpus() noexcept;
|
||||
int getNumCpus() noexcept;
|
||||
|
||||
/** Returns the approximate CPU speed.
|
||||
@returns the speed in megahertz, e.g. 1500, 2500, 32000 (depending on
|
||||
what year you're reading this...)
|
||||
*/
|
||||
static int getCpuSpeedInMegaherz();
|
||||
int getCpuSpeedInMegaherz();
|
||||
|
||||
/** Returns a string to indicate the CPU vendor.
|
||||
Might not be known on some systems.
|
||||
*/
|
||||
static String getCpuVendor();
|
||||
String getCpuVendor();
|
||||
|
||||
static bool hasMMX() noexcept; /**< Returns true if Intel MMX instructions are available. */
|
||||
static bool hasSSE() noexcept; /**< Returns true if Intel SSE instructions are available. */
|
||||
static bool hasSSE2() noexcept; /**< Returns true if Intel SSE2 instructions are available. */
|
||||
static bool hasSSE3() noexcept; /**< Returns true if Intel SSE2 instructions are available. */
|
||||
static bool has3DNow() noexcept; /**< Returns true if AMD 3DNOW instructions are available. */
|
||||
bool hasMMX() noexcept; /**< Returns true if Intel MMX instructions are available. */
|
||||
bool hasSSE() noexcept; /**< Returns true if Intel SSE instructions are available. */
|
||||
bool hasSSE2() noexcept; /**< Returns true if Intel SSE2 instructions are available. */
|
||||
bool hasSSE3() noexcept; /**< Returns true if Intel SSE2 instructions are available. */
|
||||
bool has3DNow() noexcept; /**< Returns true if AMD 3DNOW instructions are available. */
|
||||
|
||||
//==============================================================================
|
||||
/** Finds out how much RAM is in the machine.
|
||||
@returns the approximate number of megabytes of memory, or zero if
|
||||
something goes wrong when finding out.
|
||||
*/
|
||||
static int getMemorySizeInMegabytes();
|
||||
int getMemorySizeInMegabytes();
|
||||
|
||||
/** Returns the system page-size.
|
||||
This is only used by programmers with beards.
|
||||
*/
|
||||
static int getPageSize();
|
||||
int getPageSize();
|
||||
|
||||
//==============================================================================
|
||||
/** Returns a backtrace of the current call-stack.
|
||||
The usefulness of the result will depend on the level of debug symbols
|
||||
that are available in the executable.
|
||||
*/
|
||||
static String getStackBacktrace();
|
||||
String getStackBacktrace();
|
||||
|
||||
/** A void() function type, used by setApplicationCrashHandler(). */
|
||||
typedef void (*CrashHandlerFunction)();
|
||||
@@ -172,14 +171,7 @@ public:
|
||||
You may want to call getStackBacktrace() in your handler function, to find out
|
||||
where the problem happened and log it, etc.
|
||||
*/
|
||||
static void setApplicationCrashHandler (CrashHandlerFunction);
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
|
||||
SystemStats() = delete;
|
||||
SystemStats (SystemStats const&) = delete;
|
||||
SystemStats const& operator= (SystemStats const&) = delete;
|
||||
void setApplicationCrashHandler (CrashHandlerFunction);
|
||||
};
|
||||
|
||||
} // beast
|
||||
|
||||
@@ -34,9 +34,8 @@ namespace beast {
|
||||
|
||||
@see Thread, BEASTApplication
|
||||
*/
|
||||
class Process
|
||||
namespace Process
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
enum ProcessPriority
|
||||
{
|
||||
@@ -51,7 +50,7 @@ public:
|
||||
@param priority the process priority, where
|
||||
0=low, 1=normal, 2=high, 3=realtime
|
||||
*/
|
||||
static void setPriority (const ProcessPriority priority);
|
||||
void setPriority (const ProcessPriority priority);
|
||||
|
||||
/** Kills the current process immediately.
|
||||
|
||||
@@ -61,18 +60,18 @@ public:
|
||||
|
||||
@see BEASTApplication::quit
|
||||
*/
|
||||
static void terminate();
|
||||
void terminate();
|
||||
|
||||
//==============================================================================
|
||||
/** Returns true if this application process is the one that the user is
|
||||
currently using.
|
||||
*/
|
||||
static bool isForegroundProcess();
|
||||
bool isForegroundProcess();
|
||||
|
||||
/** Attempts to make the current process the active one.
|
||||
(This is not possible on some platforms).
|
||||
*/
|
||||
static void makeForegroundProcess();
|
||||
void makeForegroundProcess();
|
||||
|
||||
//==============================================================================
|
||||
/** Raises the current process's privilege level.
|
||||
@@ -80,21 +79,21 @@ public:
|
||||
Does nothing if this isn't supported by the current OS, or if process
|
||||
privilege level is fixed.
|
||||
*/
|
||||
static void raisePrivilege();
|
||||
void raisePrivilege();
|
||||
|
||||
/** Lowers the current process's privilege level.
|
||||
|
||||
Does nothing if this isn't supported by the current OS, or if process
|
||||
privilege level is fixed.
|
||||
*/
|
||||
static void lowerPrivilege();
|
||||
void lowerPrivilege();
|
||||
|
||||
/** Returns true if this process is being hosted by a debugger. */
|
||||
static bool isRunningUnderDebugger();
|
||||
bool isRunningUnderDebugger();
|
||||
|
||||
//==============================================================================
|
||||
/** Tries to launch the OS's default reader application for a given file or URL. */
|
||||
static bool openDocument (const String& documentURL, const String& parameters);
|
||||
bool openDocument (const String& documentURL, const String& parameters);
|
||||
|
||||
#if BEAST_WINDOWS || DOXYGEN
|
||||
//==============================================================================
|
||||
@@ -111,7 +110,7 @@ public:
|
||||
to provide the correct module handle in your DllMain() function, because
|
||||
the system relies on the correct instance handle when opening windows.
|
||||
*/
|
||||
static void* getCurrentModuleInstanceHandle() noexcept;
|
||||
void* getCurrentModuleInstanceHandle() noexcept;
|
||||
|
||||
/** WINDOWS ONLY - Sets a new module handle to be used by the library.
|
||||
|
||||
@@ -120,19 +119,14 @@ public:
|
||||
|
||||
@see getCurrentModuleInstanceHandle()
|
||||
*/
|
||||
static void setCurrentModuleInstanceHandle (void* newHandle) noexcept;
|
||||
void setCurrentModuleInstanceHandle (void* newHandle) noexcept;
|
||||
#endif
|
||||
|
||||
#if BEAST_MAC || DOXYGEN
|
||||
//==============================================================================
|
||||
/** OSX ONLY - Shows or hides the OSX dock icon for this app. */
|
||||
static void setDockIconVisible (bool isVisible);
|
||||
void setDockIconVisible (bool isVisible);
|
||||
#endif
|
||||
|
||||
private:
|
||||
Process() = delete;
|
||||
Process (Process const&) = delete;
|
||||
Process const& operator= (Process const&) = delete;
|
||||
};
|
||||
|
||||
} // beast
|
||||
|
||||
Reference in New Issue
Block a user