From c4811dd1b73b37b0916803097237acd31f1df98b Mon Sep 17 00:00:00 2001 From: Harsh Sharma Date: Tue, 7 Jan 2020 15:50:56 -0600 Subject: Refactored accessory cards classes with inheritence, fixed Makefile clean, moved some helper functions to header utility --- include/Utility/Utility.h | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 include/Utility/Utility.h (limited to 'include/Utility/Utility.h') diff --git a/include/Utility/Utility.h b/include/Utility/Utility.h new file mode 100644 index 0000000..062e422 --- /dev/null +++ b/include/Utility/Utility.h @@ -0,0 +1,56 @@ +#ifndef UTILITIES_H_ +#define UTILITIES_H_ + +#include "General.h" +#include "Version.h" + +/********************************************************************** +* COPYRIGHT 2020 MULTI-TECH SYSTEMS, INC. +* +* ALL RIGHTS RESERVED BY AND FOR THE EXCLUSIVE BENEFIT OF +* MULTI-TECH SYSTEMS, INC. +* +* MULTI-TECH SYSTEMS, INC. - CONFIDENTIAL AND PROPRIETARY +* INFORMATION AND/OR TRADE SECRET. +* +* NOTICE: ALL CODE, PROGRAM, INFORMATION, SCRIPT, INSTRUCTION, +* DATA, AND COMMENT HEREIN IS AND SHALL REMAIN THE CONFIDENTIAL +* INFORMATION AND PROPERTY OF MULTI-TECH SYSTEMS, INC. +* USE AND DISCLOSURE THEREOF, EXCEPT AS STRICTLY AUTHORIZED IN A +* WRITTEN AGREEMENT SIGNED BY MULTI-TECH SYSTEMS, INC. IS PROHIBITED. +* +***********************************************************************/ + +inline bool fileExists(std::string file) { + struct stat buffer; + return (stat (file.c_str(), &buffer) == 0) ? true : false; +} + +inline std::string toCamelCase(const char * d_name) { + std::string camelString = strdup(d_name); + std::string tempString = ""; + for (size_t x = 0; x < camelString.length(); x++){ + if (camelString[x] == '-' || camelString[x] == '_'){ + tempString = camelString.substr(x + 1, 1); + transform(tempString.begin(), tempString.end(), tempString.begin(), toupper); + camelString.erase(x, 2); + camelString.insert(x, tempString); + } + } + return camelString; +} + +inline void exitHandler(int code) { + if (code != 0) { + std::cout << "exiting with " << std::to_string(code); + } + exit(code); +} + +inline mode_t fileType(std::string file) { + struct stat buf; + stat (file.c_str(), &buf); + return buf.st_mode & S_IFMT; +} + +#endif /* UTILITIES_H_ */ -- cgit v1.2.3