Ace Library
Ace Library is a Windows C++ library I created that contains a series of convenience functions. Below is a list of the functions currently included with the library.
Requirements
- C++ 11
- Windows
Update 2.0: I implemented all functions to use memory alignment. This is for two reasons, one is because with the advent of C++ 11, it is now much easier to have a more universal way to align memory. The second reason is by the definition of memory alignment; it is always more efficient to have aligned memory then unaligned. This is because modern processors silently handle unaligned memory but it causes a slight performance hit because it has to do two reads instead of one read, and when there are many instructions that can add up fast. Since Ace Library now uses memory alignment, you must use _aligned_free() to delete/free any output buffers or objects from Ace Library. Otherwise you will get a “triggered break point error” or a run-time error.
Update 3.0: I implemented standard math functions in compliance with the CERT Coding Standard. Math functions are now correctly checked for domain and range errors.
Update 5.0: I implemented #ifndef for some constants that might not be recognized by some compilers.
♠
void* | _Aligned_Calloc(size_t size, size_t alignment); |
double | AbsoluteValue(double num); |
float | AbsoluteValue(float num); |
int | AbsoluteValue(int num); |
char* | AllocateAndCopyString(char* strToCopy); |
wchar_t* | AllocateAndCopyString(wchar_t* wideStrToCopy); |
double | ArcCos(double numInRadians); |
float | ArcCos(float numInRadians); |
int | ArcCos(int numInRadians); |
double | ArcCosH(double numInRadians); |
float | ArcCosH(float numInRadians); |
int | ArcCosH(int numInRadians); |
double | ArcSin(double numInRadians); |
float | ArcSin(float numInRadians); |
int | ArcSin(int numInRadians); |
double | ArcSinH(double numInRadians); |
float | ArcSinH(float numInRadians); |
int | ArcSinH(int numInRadians); |
double | ArcTan(double numInRadians); |
float | ArcTan(float numInRadians); |
int | ArcTan(int numInRadians); |
double | ArcTanH(double numInRadians); |
float | ArcTanH(float numInRadians); |
int | ArcTanH(int numInRadians); |
double | ArcTan2(double yInRadians, double xInRadians); |
float | ArcTan2(float yInRadians, float xInRadians); |
int | ArcTan2(int yInRadians, int xInRadians); |
void | CalculateAspectRatio(int newWidth, int newHeight, int originalWidth, int originalHeight, int& outAdjustedWidth, int& outAdjustedHeight); |
LONGLONG | CalculateFileSize(char* theFilePath); |
LONGLONG | CalculateFileSize(wchar_t* theFilePath); |
int | CalculateNumLength(int num); |
long | CalculateNumLength(long num); |
double | Ceiling(double num); |
float | Ceiling(float num); |
int | Ceiling(int num); |
char | CharAt(char* str, int index); |
wchar_t | CharAt(wchar_t* str, int index); |
double | ComplementaryErrorFunction(double num); |
float | ComplementaryErrorFunction(float num); |
int | ComplementaryErrorFunction(int num); |
char* | ConcatenateStrings(int numStrings, char** stringArray); |
wchar_t* | ConcatenateStrings(int numStrings, wchar_t** stringArray); |
char* | ConcatenateStrings(vector<char*> stringVectorArray); |
wchar_t* | ConcatenateStrings(vector<wchar_t*> stringVectorArray); |
char* | Concatenate(int numStrings, …); |
wchar_t* | ConcatenateW(int numWideStrings, …); |
bool | Contains(char* strToSearch, char* strToLookFor); |
bool | Contains(wchar_t* strToSearch, wchar_t* strToLookFor); |
bool | ContainsIgnoreCase(char* strToSearch, char* strToLookFor); |
bool | ContainsIgnoreCase(wchar_t* strToSearch, wchar_t* strToLookFor); |
bool | ConvertDoubleToBool(double num); |
bool | ConvertFloatToBool(float num); |
bool | ConvertIntToBool(int num); |
char* | ConvertIntToString(int integerToConvert); |
wchar_t* | ConvertIntToWideString(int integerToConvert); |
vector<char*> | ConvertStringArrayToStringVectorArray(char** stringArray); |
vector<wchar_t*> | ConvertStringArrayToStringVectorArray(wchar_t** stringArray); |
bool | ConvertStringToBool(char* str); |
bool | ConvertStringToBool(wchar_t* str); |
float* | ConvertStringToFloatArray(char* strToConvert, char* delimiter, int& outNumItems); |
float* | ConvertStringToFloatArray(wchar_t* strToConvert, wchar_t* delimiter, int& outNumItems); |
unsigned int | ConvertStringToHex(char* str); |
unsigned int | ConvertStringToHex(wchar_t* str); |
char* | ConvertStringToOneLine(char* strToConvert); |
wchar_t* | ConvertStringToOneLine(wchar_t* strToConvert); |
void | ConvertStringToOneLineInPlace(char* strToConvert); |
void | ConvertStringToOneLineInPlace(wchar_t* strToConvert); |
wchar_t* | ConvertStringToWCharString(const char* strToConvert); |
char** | ConvertStringVectorArrayToStringArray(vector<char*> stringVectorArray, int& outStringArrayLength); |
wchar_t** | ConvertStringVectorArrayToStringArray(vector<wchar_t*> stringVectorArray, int& outStringArrayLength); |
char | ConvertToLowerCase(char character); |
wchar_t | ConvertToLowerCase(wchar_t character); |
char | ConvertToUpperCase(char character); |
wchar_t | ConvertToUpperCase(wchar_t character); |
char* | ConvertToLowerCase(char* str); |
wchar_t* | ConvertToLowerCase(wchar_t* str); |
void | ConvertToLowerCaseInPlace(char* str); |
void | ConvertToLowerCaseInPlace(wchar_t* str); |
char* | ConvertToUpperCase(char* str); |
wchar_t* | ConvertToUpperCase(wchar_t* str); |
void | ConvertToUpperCaseInPlace(char* str); |
void | ConvertToUpperCaseInPlace(wchar_t* str); |
double | Cos(double numInRadians); |
float | Cos(float numInRadians); |
int | Cos(int numInRadians); |
double | CosH(double numInRadians); |
float | CosH(float numInRadians); |
int | CosH(int numInRadians); |
int | CountNumOccurrences(char* strToSearch, char charToLookFor); |
int | CountNumOccurrences(wchar_t* strToSearch, wchar_t charToLookFor); |
int | CountNumOccurrences(char* strToSearch, char* strToLookFor); |
int | CountNumOccurrences(wchar_t* strToSearch, wchar_t* strToLookFor); |
double | CubeRoot(double num); |
float | CubeRoot(float num); |
int | CubeRoot(int num); |
double | DegreesToRadians(double degrees); |
float | DegreesToRadians(float degrees); |
int | DegreesToRadians(int degrees); |
bool | DoesFileExist(char* fullFilePathWithNameAndExt); |
bool | DoesFileExist(wchar_t* fullFilePathWithNameAndExt); |
double | ErrorFunction(double num); |
float | ErrorFunction(float num); |
int | ErrorFunction(int num); |
bool | Equals(char* strToCompOne, char* strToCompTwo); |
bool | Equals(wchar_t* strToCompOne, wchar_t* strToCompTwo); |
bool | EqualsIgnoreCase(char* strToCompOne, char* strToCompTwo); |
bool | EqualsIgnoreCase(wchar_t* strToCompOne, wchar_t* strToCompTwo); |
double | EToTheXPower(double power); |
float | EToTheXPower(float power); |
int | EToTheXPower(int power); |
double | EToTheXPowerMinusOne(double power); |
float | EToTheXPowerMinusOne(float power); |
int | EToTheXPowerMinusOne(int power); |
char | FirstChar(char* str); |
wchar_t | FirstChar(wchar_t* str); |
double | Floor(double num); |
float | Floor(float num); |
int | Floor(int num); |
double | GammaFunction(double num); |
float | GammaFunction(float num); |
int | GammaFunction(int num); |
int | GenerateRandomNum(int min, int max); |
char* | GetHResultDescription(HRESULT result); |
wchar_t* | GetHResultDescriptionW(HRESULT result); |
void | GetImageSize(char* fileName, int* outWidth, int* outHeight); |
void | GetImageSizeW(wchar_t* fileName, int* outWidth, int* outHeight); |
double | Hypotenuse(double x, double y); |
float | Hypotenuse(float x, float y); |
int | Hypotenuse(int x, int y); |
int | IndexOf(char* strToSearch, char charToLookFor); |
int | IndexOf(wchar_t* strToSearch, wchar_t charToLookFor); |
int | IndexOf(char* strToSearch, char* strToLookFor); |
int | IndexOf(wchar_t* strToSearch, wchar_t* strToLookFor); |
int | IndexOfFirstLetter(char* strToSearch); |
int | IndexOfFirstLetter(wchar_t* strToSearch); |
int | IndexOfIgnoreCase(char* strToSearch, char charToLookFor); |
int | IndexOfIgnoreCase(wchar_t* strToSearch, wchar_t charToLookFor); |
int | IndexOfIgnoreCase(char* strToSearch, char* strToLookFor); |
int | IndexOfIgnoreCase(wchar_t* strToSearch, wchar_t* strToLookFor); |
char* | InsertString(char* strToReceive, char* strToInsert, int startIndex); |
wchar_t* | InsertString(wchar_t* strToReceive, wchar_t* strToInsert, int startIndex); |
bool | IsAlphabetic(char character); |
bool | IsAlphabetic(wchar_t character); |
bool | IsDigit(char character); |
bool | IsDigit(wchar_t character); |
bool | IsEmpty(char* str); |
bool | IsEmpty(wchar_t* str); |
bool | IsNumber(char* str); |
bool | IsNumber(wchar_t* str); |
bool | IsPathADevice(const char* path); |
bool | IsPathADevice(const wchar_t* path); |
bool | IsWhitespace(char character); |
bool | IsWhitespace(wchar_t character); |
double | Largest(double num1, double num2); |
float | Largest(float num1, float num2); |
int | Largest(int num1, int num2); |
char | LastChar(char* str); |
wchar_t | LastChar(wchar_t* str); |
int | LastIndexOf(char* strToSearch, char* strToLookFor); |
int | LastIndexOf(wchar_t* strToSearch, wchar_t* strToLookFor); |
double | LogBaseTen(double num); |
float | LogBaseTen(float num); |
int | LogBaseTen(int num); |
double | LogBaseTwo(double num); |
float | LogBaseTwo(float num); |
int | LogBaseTwo(int num); |
double | Mod(double numerator, double denominator); |
float | Mod(float numerator, float denominator); |
int | Mod(int numerator, int denominator); |
double | MultiplyThenAdd(double multOne, double multTwo, double add); |
float | MultiplyThenAdd(float multOne, float multTwo, float add); |
int | MultiplyThenAdd(int multOne, int multTwo, int add); |
double | NaturalLog(double num); |
float | NaturalLog(float num); |
int | NaturalLog(int num); |
double | NaturalLogGammaFunction(double num); |
float | NaturalLogGammaFunction(float num); |
int | NaturalLogGammaFunction(int num); |
int | NextIndexOf(char* strToSearch, char charToLookFor, int startIndex); |
int | NextIndexOf(wchar_t* strToSearch, wchar_t charToLookFor, int startIndex); |
int | NextIndexOf(char* strToSearch, char* strToLookFor, int startIndex); |
int | NextIndexOf(wchar_t* strToSearch, wchar_t* strToLookFor, int startIndex); |
double | NumTimesTwoToTheXPower(double num, double power); |
float | NumTimesTwoToTheXPower(float num, float power); |
int | NumTimesTwoToTheXPower(int num, int power); |
double | Power(double base, double exponent); |
float | Power(float base, float exponent); |
int | Power(int base, int exponent); |
double | PositiveDifference(double numOne, double numTwo); |
float | PositiveDifference(float numOne, float numTwo); |
int | PositiveDifference(int numOne, int numTwo); |
double | RadiansToDegrees(double radians); |
float | RadiansToDegrees(float radians); |
int | RadiansToDegrees(int radians); |
char* | ReadTextFile(char* filePath, size_t numBytesToRead, size_t maxBufferSize, const char* mode, int seekOffset, int seekOrigin, long* outEndCursorPos); |
wchar_t* | ReadTextFileW(wchar_t* filePath, size_t numBytesToRead, size_t maxBufferSize, const wchar_t* mode, int seekOffset, int seekOrigin, long* outEndCursorPos); |
char* | ReadBinaryFile(char* filePath, size_t numBytesToRead, size_t maxBufferSize, const char* mode, int seekOffset, int seekOrigin, long* outEndCursorPos); |
wchar_t* | ReadBinaryFileW(wchar_t* filePath, size_t numBytesToRead, size_t maxBufferSize, const wchar_t* mode, int seekOffset, int seekOrigin, long* outEndCursorPos); |
vector<char*> | RetrieveFileNames(char* fullFilePath); |
double | Remainder(double numerator, double denominator); |
float | Remainder(float numerator, float denominator); |
int | Remainder(int numerator, int denominator); |
double | RemainderWithQuadrant(double numerator, double denominator, int* outQuadrant); |
float | RemainderWithQuadrant(float numerator, float denominator, int* outQuadrant); |
int | RemainderWithQuadrant(int numerator, int denominator, int* outQuadrant); |
char* | RemoveAllWhitespace(char* str); |
wchar_t* | RemoveAllWhitespace(wchar_t* str); |
void | RemoveAllWhitespaceInPlace(char* str); |
void | RemoveAllWhitespaceInPlace(wchar_t* str); |
char* | RemoveCharactersFromString(char* strToRemoveFrom, char charToRemove); |
wchar_t* | RemoveCharactersFromString(wchar_t* strToRemoveFrom, wchar_t charToRemove); |
void | RemoveCharactersFromStringInPlace(char* strToRemoveFrom, char charToRemove); |
void | RemoveCharactersFromStringInPlace(wchar_t* strToRemoveFrom, wchar_t charToRemove); |
char* | RemoveStringFromString(char* strToRemoveFrom, char* strToRemove, bool removeOnlyFirstOccurrence); |
wchar_t* | RemoveStringFromString(wchar_t* strToRemoveFrom, wchar_t* strToRemove, bool removeOnlyFirstOccurrence); |
void | RemoveStringFromStringInPlace(char*& strToRemoveFrom, char* strToRemove, bool removeOnlyFirstOccurrence); |
void | RemoveStringFromStringInPlace(wchar_t*& strToRemoveFrom, wchar_t* strToRemove, bool removeOnlyFirstOccurrence); |
char* | ReplaceString(char* strToSearch, char* strToLookFor, char* strToReplaceWith, bool removeOnlyFirstOccurrence); |
wchar_t* | ReplaceString(wchar_t* strToSearch, wchar_t* strToLookFor, wchar_t* strToReplaceWith, bool removeOnlyFirstOccurrence); |
void | ReplaceStringInPlace(char*& strToSearch, char* strToLookFor, char* strToReplaceWith, bool removeOnlyFirstOccurrence); |
void | ReplaceStringInPlace(wchar_t*& strToSearch, wchar_t* strToLookFor, wchar_t* strToReplaceWith, bool removeOnlyFirstOccurrence); |
char* | RetrieveDataBetweenTags(char* fileData, char* startTag, char* endTag); |
wchar_t* | RetrieveDataBetweenTags(wchar_t* fileData, wchar_t* startTag, wchar_t* endTag); |
char* | RetrieveDataBetweenTags(char* fileData, int startTagIndex, int endTagIndex); |
wchar_t* | RetrieveDataBetweenTags(wchar_t* fileData, int startTagIndex, int endTagIndex); |
char** | RetrieveDataChunksBetweenTags(char* fileData, char* startTag, char* endTag, int& outFinalBufferSize); |
wchar_t** | RetrieveDataChunksBetweenTags(wchar_t* fileData, wchar_t* startTag, wchar_t* endTag<, int& outFinalBufferSize); |
vector<wchar_t*> | RetrieveFileNames(wchar_t* fullFilePath); |
vector<char*> | RetrieveFolderNames(char* fullFilePath); |
vector<wchar_t*> | RetrieveFolderNames(wchar_t* fullFilePath); |
char* | ReverseString(char* strToReverse); |
wchar_t* | ReverseString(wchar_t* strToReverse); |
void | ReverseStringInPlace(char* strToReverse); |
void | ReverseStringInPlace(wchar_t* strToReverse); |
long | RoundToNearestInteger(double num); |
long | RoundToNearestInteger(float num); |
long | RoundToNearestInteger(int num); |
long | RoundUp(double num); |
long | RoundUp(float num); |
long | RoundUp(int num); |
void | ShowMessageBox(HWND hWindow, char* message, char* title); |
void | ShowMessageBox(HWND hWindow, wchar_t* message, wchar_t* title); |
double | Sin(double numInRadians); |
float | Sin(float numInRadians); |
int | Sin(int numInRadians); |
double | SinH(double numInRadians); |
float | SinH(float numInRadians); |
int | SinH(int numInRadians); |
double | Smallest(double num1, double num2); |
float | Smallest(float num1, float num2); |
int | Smallest(int num1, int num2); |
double | SquareRoot(double num); |
float | SquareRoot(float num); |
int | SquareRoot(int num); |
char* | SubString(char* str, int startIndex, int upToButNotIncludingIndex); |
wchar_t* | SubString(wchar_t* str, >int startIndex, int upToButNotIncludingIndex); |
double | Tan(double numInRadians); |
float | Tan(float numInRadians); |
int | Tan(int numInRadians); |
double | TanH(double numInRadians); |
float | TanH(float numInRadians); |
int | TanH(int numInRadians); |
char** | Tokenize(char* strToTokenize, char* delimiter, int& outNumTokensFound); |
wchar_t** | Tokenize(wchar_t* strToTokenize, wchar_t* delimiter, int& outNumTokensFound); |
double | Truncate(double num); |
float | Truncate(float num); |
double | TwoToTheXPower(double power); |
float | TwoToTheXPower(float power); |
int | TwoToTheXPower(int power); |
bool | Validate(HWND hWnd, HRESULT result, char* message, char* title); |
bool | Validate(HWND hWnd, HRESULT result, wchar_t* messagem wchar_t* title); |
size_t | WriteTextFile(char* filePath<, char* bufferToWrite, size_t bufferSize, const char* mode, int seekOffset, int seekOrigin, long* outEndCursorPos); |
size_t | WriteTextFileW(wchar_t* filePath<, wchar_t* bufferToWrite, size_t bufferSize, const wchar_t* mode, int seekOffset, int seekOrigin, long* outEndCursorPos); |
size_t | WriteBinaryFile(char* filePath, char* bufferToWrite, size_t bufferSize, const char* mode, int seekOffse, int seekOrigin, long* outEndCursorPos); |
size_t | WriteBinaryFileW(wchar_t* filePath, wchar_t* bufferToWrite, size_t bufferSize, const wchar_t* mode, int seekOffset, int seekOrigin, long* outEndCursorPos); |
♠
AceVR Library is a Windows C++ library I created that contains a series of convenience functions Specifically for Virtual Reality projects since it uses OpenVR. Below is a list of the functions currently included with the library.
Requirements
- C++ 11
- Windows
- OpenVR
I implemented all functions to use memory alignment. This is for two reasons, one is because with the advent of C++ 11, it is now much easier to have a more universal way to align memory. The second reason is by the definition of memory alignment; it is always more efficient to have aligned memory then unaligned. This is because modern processors silently handle unaligned memory but it causes a slight performance hit because it has to do two reads instead of one read, and when there are many instructions that can add up fast. Since Ace Library and AceVR Library now uses memory alignment, you must use _aligned_free() to delete/free any output buffers or objects from Ace Library and AceVR Library. Otherwise you will get a “triggered break point error” or a run-time error.
♠
XMMATRIX | ConvertSteamVRMatrixToXMMATRIX(const HmdMatrix34_t& matPose) |
---|---|
bool | GetContainsProximitySensor(IVRSystem* hmd, uint32_t deviceIndex) |
bool | GetControllerIsButtonPressed(IVRSystem* hmd, EVRButtonId button) |
bool | GetControllerIsButtonTouched(IVRSystem* hmd, EVRButtonId button) |
XMMATRIX | GetCurrentViewProjectionMatrix(IVRSystem* hmd, const XMMATRIX& projectionMat, const XMMATRIX& eyePose, const XMMATRIX& hmdPose) |
float | GetDeviceBatteryPercentage(IVRSystem* hmd, uint32_t deviceIndex) |
uint64_t | GetDeviceClass(IVRSystem* hmd, uint32_t deviceIndex) |
bool | GetDeviceIsCharging(IVRSystem* hmd, uint32_t deviceIndex) |
bool | GetDeviceIsWireless(IVRSystem* hmd, uint32_t deviceIndex) |
bool | GetDeviceProvidesBatteryStatus(IVRSystem* hmd, uint32_t deviceIndex) |
char* | GetFirmwareProgrammingTarget(IVRSystem* hmd, uint32_t deviceIndex) |
uint64_t | GetFirmwareVersion(IVRSystem* hmd, uint32_t deviceIndex) |
uint64_t | GetFPGAVersion(IVRSystem* hmd, uint32_t deviceIndex) |
bool | GetHasCamera(IVRSystem* hmd, uint32_t deviceIndex) |
uint64_t | GetHMDAudioFirmwareVersion(IVRSystem* hmd, uint32_t deviceIndex) |
uint64_t | GetHMDCameraCompatibilityMode(IVRSystem* hmd, uint32_t deviceIndex) |
uint64_t | GetHMDCurrentUniverseId(IVRSystem* hmd, uint32_t deviceIndex) |
uint64_t | GetHMDDisplayBootloaderVersion(IVRSystem* hmd, uint32_t deviceIndex) |
uint64_t | GetHMDDisplayFirmwareVersion(IVRSystem* hmd, uint32_t deviceIndex) |
float | GetHMDDisplayFrequency(IVRSystem* hmd, uint32_t deviceIndex) |
uint64_t | GetHMDDisplayHardwareVersion(IVRSystem* hmd, uint32_t deviceIndex) |
XMMATRIX | GetHMDEyePoseMatrix(IVRSystem* hmd, Hmd_Eye nEye); |
XMMATRIX | GetHMDEyeProjectionMatrix(IVRSystem* hmd, Hmd_Eye nEye, float nearClipPlane, float farClipPlane); |
uint64_t | GetHMDPreviousUniverseId(IVRSystem* hmd, uint32_t deviceIndex) |
float | GetHMDSecondsFromVsyncToPhotons(IVRSystem* hmd, uint32_t deviceIndex) |
float | GetHMDUserIpdMeters(IVRSystem* hmd, uint32_t deviceIndex) |
bool | GetIsFirmwareManualUpdate(IVRSystem* hmd, uint32_t deviceIndex) |
bool | GetIsFirmwareUpdateAvailable(IVRSystem* hmd, uint32_t deviceIndex) |
char* | GetManufacturerName(IVRSystem* hmd, uint32_t deviceIndex) |
char* | GetModelNumber(IVRSystem* hmd, uint32_t deviceIndex) |
char* | GetRenderModelName(IVRSystem* hmd, uint32_t deviceIndex) |
char* | GetSerialNumber(IVRSystem* hmd, uint32_t deviceIndex) |
char* | GetTrackingSystemName(IVRSystem* hmd, uint32_t deviceIndex) |
char* | SteamVRMatrix34ToString(const HmdMatrix34_t& mat) |
char* | SteamVRMatrix44ToString(const HmdMatrix44_t& mat) |
char* | XMMatrixToString(const XMMATRIX& mat) |