![]() |
Gray C++ Libraries
0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
|
#include <cAppState.h>
Public Member Functions | |
APPSTATE_TYPE_ | get_AppState () const noexcept |
void | put_AppState (APPSTATE_TYPE_ eAppState) noexcept |
void | InitAppState () noexcept |
THREADID_t | get_MainThreadId () const noexcept |
cStringF | get_TempDir () |
cStringF | GetTempFile (const FILECHAR_t *pszFileTitle) |
cStringF | GetTempDir (const FILECHAR_t *pszFileDir, bool bCreate=true) |
void | SetArgValid (ITERATE_t i) |
cStringF | get_InvalidArgs () const |
void | InitArgsF (const FILECHAR_t *pszCommandArgs) |
void | InitArgs2 (int argc, APP_ARGS_t argv) |
const void * | get_HeapPtr () const noexcept override |
Get the top level (outermost, freeable) class pointer. I can delete get_HeapPtr(). More... | |
![]() | |
virtual | ~CObject () |
virtual bool | isValidCheck () const noexcept |
< memory allocation and structure definitions are valid. More... | |
virtual void | AssertValid () const |
< memory allocation and structure definitions are valid. More... | |
virtual void | Serialize (cArchive &a) |
![]() | |
cHeapObject () | |
virtual | ~cHeapObject () |
bool | IsValidInsideN (INT_PTR index) const |
bool | IsValidInsidePtr (void const *pTest) const |
virtual size_t | GetHeapStatsThis (OUT ITERATE_t &iAllocCount) const |
virtual bool | isValidCheck () const noexcept |
Static Public Member Functions | |
static cStringF __stdcall | get_AppFilePath () |
The full path+name of the current EXE/PE. More... | |
static cStringF __stdcall | get_AppFileTitle () |
File name no Ext. More... | |
static cStringF __stdcall | get_AppFileDir () |
static HRESULT | CheckValidSignature (UINT32 nGrayCoreVer, size_t nSizeofThis) |
static APPSTATE_TYPE_ __stdcall | GetAppState () |
static bool __stdcall | isInCInit () |
static bool __stdcall | isAppRunning () |
static bool __stdcall | isAppStateRun () |
static bool __stdcall | isInCExit () |
static bool __stdcall | isDebuggerPresent () |
static bool __stdcall | isRemoteSession () |
static void __stdcall | SetExecutionState (bool bActiveCPU, bool bActiveGUI) |
static bool __stdcall | isCurrentUserAdmin () |
static cString __stdcall | GetCurrentUserName (bool bForce=false) |
static cStringF __stdcall | GetCurrentUserDir (const FILECHAR_t *pszSubFolder=nullptr, bool bCreate=true) |
Get Root folder the user has write access to. More... | |
static PROCESSID_t __stdcall | get_CurrentProcessId () |
static HMODULE __stdcall | get_HModule () |
static UINT __stdcall | get_LibVersion () |
_INC_GrayCore_H More... | |
static StrLen_t __stdcall | GetEnvironStr (const FILECHAR_t *pszVarName, FILECHAR_t *pszValue, StrLen_t iLenMax) noexcept |
static cStringF __stdcall | GetEnvironStr (const FILECHAR_t *pszVarName) noexcept |
environment variable. from (system,user,app) More... | |
static ITERATE_t __stdcall | GetEnvironArray (cArrayString< FILECHAR_t > &a) |
static bool __stdcall | SetEnvironStr (const FILECHAR_t *pszVarName, const FILECHAR_t *pszVal) |
static StrLen_t __stdcall | GetCurrentDir (FILECHAR_t *pszDir, StrLen_t iSizeMax) |
Current default directory for the app. More... | |
static cStringF __stdcall | get_CurrentDir () |
For the process. Not applicable to WINCE. More... | |
static bool __stdcall | SetCurrentDir (const FILECHAR_t *pszDir) |
static void __stdcall | AbortApp (APP_EXITCODE_t uExitCode=APP_EXITCODE_ABORT) |
![]() | |
static cAppState *__stdcall | get_Single () |
static TYPE2 *__stdcall | get_SingleT () |
static cAppState &__stdcall | I () |
![]() | |
static bool | isSingleCreated () noexcept |
static TYPE * | get_SingleU () noexcept |
static TYPE * | get_Single () |
template<class TYPE2 > | |
static TYPE2 *__stdcall | get_SingleCast () |
static TYPE & | I () noexcept |
![]() | |
static void __stdcall | ReleaseModule (HMODULE hMod) |
Public Attributes | |
const cObjectSignature | m_Sig |
Used to check for compatible build/compile config and alignments. (_INC_GrayCore_H, sizeof(cAppState)) More... | |
cThreadLocalSysT< bool > | m_ThreadModuleLoading |
any thread is currently loading a DLL/SO? isInCInit(). use cAppStateModuleLoad More... | |
cAppArgs | m_Args |
Application Command line arguments. [0] = app name. More... | |
cBitmask | m_ArgsValid |
Track which command line args are valid/used in m_Args. assume any left over are not. More... | |
Static Public Attributes | |
static HMODULE | sm_hInstance = HMODULE_NULL |
the current applications HINSTANCE handle/base address. _IMAGE_DOS_HEADER, HMODULE=HINSTANCE More... | |
![]() | |
static cThreadLockFast | sm_LockSingle |
common lock for all cSingleton. More... | |
Protected Member Functions | |
cAppState () | |
virtual | ~cAppState () |
![]() | |
cSingleton (cAppState *pObject, const TYPEINFO_t &rAddrCode=typeid(cAppState)) noexcept | |
virtual | ~cSingleton () |
![]() | |
cSingletonStatic (TYPE *pObject) noexcept | |
virtual | ~cSingletonStatic () noexcept |
![]() | |
cSingletonRegister (const TYPEINFO_t &rAddrCode) noexcept | |
virtual | ~cSingletonRegister () |
void | RegisterSingleton () |
![]() | |
const void * | get_HeapPtr () const noexcept override |
Get the top level (outermost, freeable) class pointer. I can delete get_HeapPtr(). More... | |
Protected Attributes | |
THREADID_t | m_nMainThreadId |
The thread we started with. main(). More... | |
APPSTATE_TYPE_ | m_eAppState |
The main state of the application. use isInCInit() for loading DLL's. More... | |
cString | m_sUserName |
Applications assigned login/user name. Cache/Read this just once. More... | |
cStringF | m_sTempDir |
Cache my temporary files directory path. More... | |
bool | m_bTempDirWritable |
I have test written to the temp directory. its good. More... | |
![]() | |
HMODULE | m_hModuleLoaded |
What modules loaded this ? So singletons can be destroyed if DLL/SO unloads. More... | |
Friends | |
class | cSingleton< cAppState > |
class | cAppImpl |
class | cAppStateMain |
class | cUnitTestAppState |
class | cAppStateTests |
Additional Inherited Members | |
![]() | |
static TYPE * | sm_pThe = nullptr |
pointer to the one and only object of this TYPE. ASSUME automatically init to = nullptr. More... | |
Singleton to track the state of the current running app/process. Don't combine this with CWinApp/cAppImpl since we may be a (dll/Shared) library or using this in static init. Track when static init is complete and when static destructors are called.
|
protected |
Cache the OS params for this process/app ?
|
protectedvirtual |
|
static |
Abort the application from some place other than the main() or WinMain() fall through. Call this instead of abort() or exit() to preclude naughty libraries from exiting badly.
|
inlinestatic |
Is this the correct version of cAppState? Must be agreed to by all users. sizeof(cAppState) for checking alignments of structures. Ensure that some external DLL/SO caller has the same structure packing that we have.
The full path+name of the current EXE/PE.
like _pgmptr in POSIX
File name no Ext.
Get the title of the app EXE file. No extension.
|
inlinenoexcept |
use isInCInit() for loading DLL's.
For the process. Not applicable to WINCE.
|
inlinestatic |
similar to cOSProcess
|
inlineoverridevirtualnoexcept |
Get the top level (outermost, freeable) class pointer. I can delete get_HeapPtr().
Implements Gray::IHeapObject.
|
static |
Same as HINSTANCE Passed to app at start in _WIN32 WinMain(HINSTANCE hInstance)
cStringF Gray::cAppState::get_InvalidArgs | ( | ) | const |
Get a list of args NOT marked as valid. Not IN m_ValidArgs
|
static |
_INC_GrayCore_H
|
inlinenoexcept |
The thread we started with.
cStringF Gray::cAppState::get_TempDir | ( | ) |
Get a directory i can place temporary files. ends with '\' This is decided based on the OS,User,App, Similar to _FNF(::SHGetFolderPath)(CSIDL_INTERNET_CACHE) Assume cInstallDir::IsInstallDirRestricted()
|
static |
|
static |
Current default directory for the app.
return the current directory for the process. In linux and _WIN32 the Process has a current/default directory. UNDER_CE does not.
|
static |
Get Root folder the user has write access to.
get a folder the user has write access to. for placing log files and such.
Get the current system user name for the process/app.
|
static |
Get the full block of environ strings for this process. similar to cVarMap or cIniSectionData Each entry is in the form "Var1=Value1" http://linux.die.net/man/7/environ
|
staticnoexcept |
environment variable. from (system,user,app)
Get a named environment variable by name.
|
staticnoexcept |
Get a named environment variable by name.
cStringF Gray::cAppState::GetTempDir | ( | const FILECHAR_t * | pszFileDir, |
bool | bCreate = true |
||
) |
Get/Create a temporary folder in temporary folder space.
cStringF Gray::cAppState::GetTempFile | ( | const FILECHAR_t * | pszFileTitle | ) |
Create a temporary file to store stuff. Make sure its not colliding.
|
noexcept |
The main app thread has started. often called by cAppStateMain or via InitInstance() in _MFC_VER.
void Gray::cAppState::InitArgs2 | ( | int | argc, |
APP_ARGS_t | argv | ||
) |
POSIX main() style init. If called by ServiceMain this might be redundant.
void Gray::cAppState::InitArgsF | ( | const FILECHAR_t * | pszCommandArgs | ) |
Windows style (unparsed) arguments. WinMain() Command line arguments honor "quoted strings" as a single argument. can get similar results from the win32 GetCommandLine(); (which includes the app path as arg 0) similar to _WIN32 shell32 CommandLineToArgvW( pszCommandArgs, &(dwArgc));
|
static |
Not in static init or destruct. Indicate the process/app is DONE initializing static variables. Thought it may be setting up or tearing down. Almost exit. Use cAppStateMain inmain;
|
static |
the process/app is in APPSTATE_Run? Use cAppStateMain inmain;
This routine returns 'true' if the caller's process is a member of the Administrators local group. Caller is NOT expected to be impersonating anyone and is expected to be able to open its own process and process token.
|
static |
is the app exiting right now ? outside main() extern "C" int _C_Termination_Done; // undocumented C runtime variable - set to true during auto-finalization return _C_Termination_Done; // undocumented symbol is not good in DLL.
|
static |
Indicate the process/app is currently initializing static variables. not yet reached main() Also set for a thread loading a DLL/SO.
Should we act different if this is a remote terminal?
|
inlinenoexcept |
Indicate the process/app has changed state. use cAppStateModuleLoad for DLL/SO loading.
void Gray::cAppState::SetArgValid | ( | ITERATE_t | i | ) |
|
static |
set the current directory path for the current app. like chdir() or _chdir()
|
static |
ASSUME pszVarName is valid format.
Tell the system it should not sleep/hibernate if it is active. I have a big task to complete. try this for Vista, it will fail on XP
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
cAppArgs Gray::cAppState::m_Args |
Application Command line arguments. [0] = app name.
cBitmask Gray::cAppState::m_ArgsValid |
Track which command line args are valid/used in m_Args. assume any left over are not.
|
protected |
I have test written to the temp directory. its good.
|
protected |
The main state of the application. use isInCInit() for loading DLL's.
|
protected |
The thread we started with. main().
const cObjectSignature Gray::cAppState::m_Sig |
Used to check for compatible build/compile config and alignments. (_INC_GrayCore_H, sizeof(cAppState))
|
protected |
Cache my temporary files directory path.
|
protected |
Applications assigned login/user name. Cache/Read this just once.
cThreadLocalSysT<bool> Gray::cAppState::m_ThreadModuleLoading |
any thread is currently loading a DLL/SO? isInCInit(). use cAppStateModuleLoad
|
static |
the current applications HINSTANCE handle/base address. _IMAGE_DOS_HEADER, HMODULE=HINSTANCE
the current applications HINSTANCE handle/base address. _IMAGE_DOS_HEADER