created project with cmake
This commit is contained in:
parent
c4b3d8ac5f
commit
5f6abf300e
54 changed files with 412 additions and 310 deletions
57
Software/CMakeLists.txt
Normal file
57
Software/CMakeLists.txt
Normal file
|
@ -0,0 +1,57 @@
|
|||
###########################################################################################
|
||||
#
|
||||
# (c) Technical Software Engineering Plazotta 2021
|
||||
#
|
||||
# CMAKE project main file / LSFramework
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------
|
||||
# Define project specific requirements
|
||||
#
|
||||
# Minimum CMAKE version for this project
|
||||
#
|
||||
cmake_minimum_required (VERSION 3.23.0)
|
||||
#
|
||||
# Name of the project
|
||||
set(MAIN_PROJECT_NAME LSFramework)
|
||||
project(${MAIN_PROJECT_NAME})
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------
|
||||
# Include project specific definitions -> Generated file
|
||||
#
|
||||
include(Project.conf.cmake)
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------
|
||||
# Include cmake settings and macros
|
||||
#
|
||||
include(${TSEP_PROJECT_CMAKE}/CMakeMacros.cmake)
|
||||
include(${TSEP_PROJECT_CMAKE}/CMakeSettings.cmake)
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------
|
||||
# google test framework -> enable if used
|
||||
#
|
||||
#TSEP_USE_GOOGLE_TESTING()
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------
|
||||
# Current project description
|
||||
#
|
||||
set(TSEP_PROJECT "Framework")
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------
|
||||
# Allow project folder structure
|
||||
#
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------
|
||||
# Define projects for building
|
||||
#
|
||||
add_subdirectory("Framework")
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------
|
||||
# Define projects for managing and distributing
|
||||
#
|
||||
# NEXUS Upload (Only windows)
|
||||
#
|
||||
IF(WIN32)
|
||||
|
||||
ENDIF()
|
||||
#
|
109
Software/Framework/CMakeLists.txt
Normal file
109
Software/Framework/CMakeLists.txt
Normal file
|
@ -0,0 +1,109 @@
|
|||
###########################################################################################
|
||||
#
|
||||
# (c) Technical Software Engineering Plazotta 2021
|
||||
#
|
||||
# CMAKE project file / @Add your project name@
|
||||
#
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------
|
||||
# Define project specific requirements
|
||||
#
|
||||
# Project name, output file name, project description
|
||||
#
|
||||
set(PROJECT_NAME LSFramework)
|
||||
set(PROJECT_OUTPUT_NAME LSFramework)
|
||||
set(PROJECT_DESCRIPTION "LSFramework")
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------
|
||||
# Define group file names
|
||||
#
|
||||
# SOURCE FILES
|
||||
#
|
||||
set(SOURCE_FILES
|
||||
src/Timer.cpp
|
||||
src/LSString.cpp
|
||||
)
|
||||
#
|
||||
# HEADER FILES
|
||||
#
|
||||
set(HEADER_FILES
|
||||
src/LSFramework.Exports.h
|
||||
src/LSMacros.h
|
||||
src/Timer.h
|
||||
src/CJsonDocument.h
|
||||
src/CJsonNode.h
|
||||
src/CJsonArray.h
|
||||
src/CJsonObject.h
|
||||
src/LSString.h
|
||||
src/LSList.h
|
||||
src/LSListItem.h
|
||||
src/LSVector.h
|
||||
)
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------
|
||||
# Define solution folders for group files
|
||||
#
|
||||
source_group("Source Files" FILES ${SOURCE_FILES})
|
||||
source_group("Header Files" FILES ${HEADER_FILES})
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------
|
||||
# DLL definitions
|
||||
#
|
||||
# Setup shared library version
|
||||
#
|
||||
TSEP_SETUP_DLL_VERSION(${PROJECT_DESCRIPTION})
|
||||
#
|
||||
# Create shared library target
|
||||
#
|
||||
add_library(${PROJECT_NAME} SHARED
|
||||
${SOURCE_FILES}
|
||||
${HEADER_FILES}
|
||||
${TSEP_DLL_VERSION_RC}
|
||||
)
|
||||
#
|
||||
# Add alias for the project
|
||||
#
|
||||
add_library(LS::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||
#
|
||||
# Setup TSEP OS specific settings for the project
|
||||
#
|
||||
TSEP_ADD_OS_SPECIFIC_SETTINGS()
|
||||
#
|
||||
# Setup output name
|
||||
#
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_OUTPUT_NAME})
|
||||
#
|
||||
# Use VS Code Analysis for the project
|
||||
#
|
||||
TSEP_USE_CODE_ANALYSIS(${PROJECT_NAME})
|
||||
#
|
||||
# Define Export Headers
|
||||
#
|
||||
TSEP_ADD_EXPORT_HEADER("${HEADER_FILES}")
|
||||
#
|
||||
# Include files, add your own includes and for the export
|
||||
#
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src>
|
||||
$<INSTALL_INTERFACE:inc>
|
||||
#PRIVATE
|
||||
# include paths, which will not be exported
|
||||
)
|
||||
#
|
||||
# Add used libs
|
||||
#
|
||||
#target_link_libraries(${PROJECT_NAME}
|
||||
# PUBLIC
|
||||
# /- Add your additional libraries -/
|
||||
#)
|
||||
#
|
||||
# Create an Export directory with the defined data
|
||||
#
|
||||
TSEP_CREATE_EXPORT()
|
||||
#
|
||||
#
|
||||
# Create links to necessary dependency libraries
|
||||
#
|
||||
TSEP_GENERATE_DEPENDENCY_LINKS()
|
||||
#
|
0
Software/Framework/src/CJsonArray.h
Normal file
0
Software/Framework/src/CJsonArray.h
Normal file
8
Software/Framework/src/CJsonDocument.h
Normal file
8
Software/Framework/src/CJsonDocument.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
private:
|
||||
CcJsonNode m_oJsonData;
|
||||
bool m_bParseError = false;
|
||||
CcString m_sParseErrorMsg;
|
||||
bool m_bIntend = false;
|
||||
uint16 m_uiIntendLevel = 0;
|
||||
|
||||
static const CcString c_sIndent;
|
12
Software/Framework/src/CJsonNode.h
Normal file
12
Software/Framework/src/CJsonNode.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
private:
|
||||
union CcDocumentsSHARED UJsonDataType
|
||||
{
|
||||
void* m_pVoid;
|
||||
CcVariant* m_ovValue;
|
||||
CcJsonObject* m_poJsonObject;
|
||||
CcJsonArray* m_poJsonArray;
|
||||
};
|
||||
UJsonDataType m_uData;
|
||||
EJsonDataType m_eType = EJsonDataType::Unknown; //!< Enum of current stored Object type.
|
||||
CcString m_sName; //!< Name of this Object
|
||||
};
|
0
Software/Framework/src/CJsonObject.h
Normal file
0
Software/Framework/src/CJsonObject.h
Normal file
47
Software/Framework/src/LSFramework.Exports.h
Normal file
47
Software/Framework/src/LSFramework.Exports.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/**
|
||||
* @page @Add your project name@
|
||||
*
|
||||
* @author TSEP
|
||||
*
|
||||
* @copyright (c) Technical Software Engineering Plazotta 2021
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @file @Add your project name@.Exports.h
|
||||
* @brief Definition of export declarations for this library
|
||||
*
|
||||
**************************************************************************/
|
||||
//TSEP_Pragma.UnitTest.Skip
|
||||
#pragma once
|
||||
|
||||
// Note:
|
||||
// "<project>_EXPORTS" preprocessor define is defined by CMake when compiling <project>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
// OPERATING SYSTEM : WIN32
|
||||
//----------------------------------------------------------------------------*/
|
||||
#ifdef _WIN32
|
||||
|
||||
/// @cond Exclude this macro from doxygen
|
||||
#ifdef LSFramework_EXPORTS
|
||||
#define LSFRAMEWORK_API __declspec(dllexport)
|
||||
#else
|
||||
#define LSFRAMEWORK_API __declspec(dllimport)
|
||||
#endif
|
||||
/// @endcond
|
||||
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
// OPERATING SYSTEM : LINUX
|
||||
//----------------------------------------------------------------------------*/
|
||||
#ifdef __linux__
|
||||
|
||||
#ifdef LSFRAMEWORK_EXPORTS
|
||||
#define LSFRAMEWORK_API __attribute__((visibility("default")))
|
||||
#else
|
||||
#define LSFRAMEWORK_API
|
||||
#endif
|
||||
|
||||
#endif // __linux__
|
||||
|
106
Software/Framework/src/LSList.h
Normal file
106
Software/Framework/src/LSList.h
Normal file
|
@ -0,0 +1,106 @@
|
|||
#pragma once
|
||||
#include "LSFramework.Exports.h"
|
||||
#include "LSMacros.h"
|
||||
#include "LSListItem.h"
|
||||
|
||||
template <class T>
|
||||
|
||||
class LSFRAMEWORK_API LSList
|
||||
{
|
||||
public:
|
||||
LSList()
|
||||
{
|
||||
}
|
||||
|
||||
~LSList()
|
||||
{
|
||||
DELETE_ARRAY(m_pFirst)
|
||||
DELETE_ARRAY(m_pLast)
|
||||
}
|
||||
|
||||
LSListItem<T>* Append(T tObj)
|
||||
{
|
||||
LSListItem<T>* pNewLast;
|
||||
if (!m_pFirst)
|
||||
{
|
||||
m_pFirst = new LSListItem<T>(tObj);
|
||||
m_pLast = new LSListItem<T>(tObj);
|
||||
m_pFirst->pNext = m_pLast;
|
||||
pNewLast = m_pFirst;
|
||||
}
|
||||
else
|
||||
{
|
||||
pNewLast = new LSListItem<T>(tObj);
|
||||
if (m_pLast->pBefore)
|
||||
{
|
||||
LSListItem<T>* pCurrentLast = m_pLast;
|
||||
pCurrentLast->pNext = pNewLast;
|
||||
pNewLast->pBefore = pCurrentLast;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pFirst->pNext = pNewLast;
|
||||
pNewLast->pBefore = m_pFirst;
|
||||
}
|
||||
m_pLast = pNewLast;
|
||||
}
|
||||
m_zSize++;
|
||||
return pNewLast;
|
||||
}
|
||||
|
||||
LSListItem<T>* Remove(T tObj)
|
||||
{
|
||||
if (m_zSize == 0) return nullptr;
|
||||
|
||||
LSListItem<T>* pItemToRemove = m_pFirst;
|
||||
|
||||
while (pItemToRemove->tValue != tObj)
|
||||
{
|
||||
pItemToRemove = pItemToRemove->pNext;
|
||||
}
|
||||
|
||||
LSListItem<T>* pRet = nullptr;
|
||||
|
||||
if (m_zSize <= 1)
|
||||
{
|
||||
m_pFirst = nullptr;
|
||||
m_pLast = nullptr;
|
||||
}
|
||||
else if (pItemToRemove == m_pFirst)
|
||||
{
|
||||
LSListItem<T>* pNewFirst = pItemToRemove->pNext;
|
||||
pNewFirst->pBefore = nullptr;
|
||||
m_pFirst = pNewFirst;
|
||||
pRet = pNewFirst;
|
||||
}
|
||||
else if (pItemToRemove == m_pLast)
|
||||
{
|
||||
LSListItem<T>* pNewLast = pItemToRemove->pBefore;
|
||||
pNewLast->pNext = nullptr;
|
||||
m_pLast = pNewLast;
|
||||
pRet = pNewLast;
|
||||
}
|
||||
else
|
||||
{
|
||||
LSListItem<T>* pBefore = pItemToRemove->pBefore;
|
||||
LSListItem<T>* pNext = pItemToRemove->pNext;
|
||||
pBefore->pNext = pNext;
|
||||
pNext->pBefore = pBefore;
|
||||
pRet = pNext;
|
||||
}
|
||||
|
||||
DELETE_POINTER(pItemToRemove);
|
||||
m_zSize--;
|
||||
return pRet;
|
||||
}
|
||||
|
||||
T* RemoveAt(size_t zPos)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
LSListItem<T>* m_pFirst = nullptr;
|
||||
LSListItem<T>* m_pLast = nullptr;
|
||||
size_t m_zSize = 0;
|
||||
};
|
22
Software/Framework/src/LSListItem.h
Normal file
22
Software/Framework/src/LSListItem.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
template <class T>
|
||||
|
||||
class LSListItem
|
||||
{
|
||||
public:
|
||||
LSListItem(T tObj)
|
||||
: tValue(tObj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
~LSListItem()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
LSListItem* pBefore = nullptr;
|
||||
LSListItem* pNext = nullptr;
|
||||
T tValue;
|
||||
};
|
15
Software/Framework/src/LSMacros.h
Normal file
15
Software/Framework/src/LSMacros.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#define DELETE_POINTER(pPointer) \
|
||||
if (pPointer != nullptr)\
|
||||
{\
|
||||
delete pPointer;\
|
||||
pPointer = nullptr;\
|
||||
}
|
||||
|
||||
#define DELETE_ARRAY(vArray) \
|
||||
if (vArray != nullptr)\
|
||||
{\
|
||||
delete[] vArray;\
|
||||
vArray = nullptr;\
|
||||
}
|
119
Software/Framework/src/LSString.cpp
Normal file
119
Software/Framework/src/LSString.cpp
Normal file
|
@ -0,0 +1,119 @@
|
|||
#include "LSString.h"
|
||||
#include <memory>
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
LSString::LSString(const char* pData)
|
||||
: m_zSize(StringLength(pData))
|
||||
, m_uiCapacity(StringLength(pData))
|
||||
{
|
||||
Assign(pData);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
LSString::LSString(const std::string& sRhs)
|
||||
: m_zSize(sRhs.length())
|
||||
, m_uiCapacity(sRhs.length())
|
||||
{
|
||||
Assign(sRhs);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
LSString& LSString::operator=(const LSString& sRhs)
|
||||
{
|
||||
m_zSize = sRhs.Size();
|
||||
m_uiCapacity = sRhs.Capacity();
|
||||
Assign(sRhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
LSString::LSString(const LSString& sRhs)
|
||||
: m_zSize(sRhs.m_zSize)
|
||||
, m_uiCapacity(sRhs.m_uiCapacity)
|
||||
{
|
||||
Assign(sRhs);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
LSString::~LSString()
|
||||
{
|
||||
DELETE_ARRAY(m_pData);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
void LSString::Assign(const char* pData)
|
||||
{
|
||||
m_pData = new char[m_zSize + 1];
|
||||
memset(m_pData, 0, m_zSize + 1);
|
||||
if (pData) memcpy(m_pData, pData, m_zSize);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
void LSString::Insert(const char* pData, size_t zLength, size_t zPos)
|
||||
{
|
||||
if (!pData) return;
|
||||
|
||||
size_t zNewLength = m_zSize + zLength;
|
||||
|
||||
while (zNewLength > m_uiCapacity)
|
||||
{
|
||||
IncreaseCapacity(zNewLength);
|
||||
}
|
||||
|
||||
char* pLeft = m_pData + zPos;
|
||||
char* pRight = m_pData + zPos + zLength;
|
||||
|
||||
memcpy(pRight, m_pData + zPos, m_zSize - zPos);
|
||||
memcpy(pLeft, pData, zLength);
|
||||
|
||||
m_zSize = zNewLength;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
bool LSString::RemoveAt(size_t uiPos, size_t uiSize)
|
||||
{
|
||||
if (uiPos > m_zSize) return false;
|
||||
|
||||
m_zSize = m_zSize - uiSize;
|
||||
char* pLast = m_pData + uiPos + uiSize;
|
||||
memcpy(m_pData + uiPos, pLast, uiSize);
|
||||
memset(pLast, 0, uiSize);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
size_t LSString::StringLength(const char* pChar) const
|
||||
{
|
||||
if (!pChar) return 0;
|
||||
const char* pStart = pChar;
|
||||
while (*pChar != 0x0)
|
||||
{
|
||||
pChar++;
|
||||
}
|
||||
return pChar - pStart;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
int LSString::Find(const char * pData, size_t uiOffset, size_t uiLength) const
|
||||
{
|
||||
int iRet = -1;
|
||||
while (uiOffset + uiLength <= m_zSize)
|
||||
{
|
||||
iRet = memcmp(m_pData + uiOffset, pData, uiLength);
|
||||
if (iRet == 0) break;
|
||||
uiOffset++;
|
||||
}
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
void LSString::IncreaseCapacity(size_t uiNewLength)
|
||||
{
|
||||
m_uiCapacity = uiNewLength * c_uiCapacityIncreaseFactor;
|
||||
char* pNew = new char[m_uiCapacity + 1];
|
||||
memset(pNew, 0, m_uiCapacity + 1);
|
||||
memmove(pNew, m_pData, m_zSize);
|
||||
DELETE_ARRAY(m_pData);
|
||||
m_pData = pNew;
|
||||
}
|
178
Software/Framework/src/LSString.h
Normal file
178
Software/Framework/src/LSString.h
Normal file
|
@ -0,0 +1,178 @@
|
|||
#pragma once
|
||||
#include "LSFramework.Exports.h"
|
||||
#include "LSMacros.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class LSFRAMEWORK_API LSString
|
||||
{
|
||||
public:
|
||||
// - Constructor
|
||||
LSString() = default;
|
||||
|
||||
LSString(const char* pData);
|
||||
|
||||
LSString(const LSString& sString);
|
||||
|
||||
LSString(const std::string& sString);
|
||||
|
||||
// - Operator
|
||||
LSString& operator=(const LSString& sRhs);
|
||||
|
||||
// - Destructor
|
||||
~LSString();
|
||||
|
||||
// - Alloc
|
||||
#pragma region Conversion
|
||||
inline void Assign(const LSString& sString)
|
||||
{
|
||||
Assign(sString.ToCChar());
|
||||
}
|
||||
inline void Assign(const std::string& sString)
|
||||
{
|
||||
Assign(sString.c_str());
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
inline void Append(const LSString& sRhs)
|
||||
{
|
||||
Insert(sRhs, sRhs.Size());
|
||||
}
|
||||
inline void Append(const std::string& sRhs)
|
||||
{
|
||||
Insert(sRhs, sRhs.length());
|
||||
}
|
||||
inline void Append(const char* pData)
|
||||
{
|
||||
Insert(pData, StringLength(pData), m_zSize);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
inline void Insert(const LSString& sRhs, size_t zPos)
|
||||
{
|
||||
Insert(sRhs.m_pData, sRhs.Size(), zPos);
|
||||
}
|
||||
inline void Insert(const std::string& sRhs, size_t zPos)
|
||||
{
|
||||
Insert(sRhs.c_str(), sRhs.size(), zPos);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
inline bool Remove(const LSString& sRhs)
|
||||
{
|
||||
return RemoveAt(Find(sRhs), sRhs.m_zSize);
|
||||
}
|
||||
inline bool Remove(const std::string& sRhs)
|
||||
{
|
||||
return RemoveAt(Find(sRhs), sRhs.length());
|
||||
}
|
||||
inline bool Remove(const char* pData)
|
||||
{
|
||||
return RemoveAt(Find(pData), StringLength(pData));
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Logic
|
||||
void Assign(const char* pData);
|
||||
void Insert(const char* pData, size_t zLength, size_t zPos);
|
||||
bool RemoveAt(size_t uiPos, size_t uiSize);
|
||||
#pragma endregion
|
||||
|
||||
// - Utility
|
||||
#pragma region Conversion
|
||||
inline bool Contains(const LSString& sRhs) const
|
||||
{
|
||||
return Find(sRhs) == 0;
|
||||
}
|
||||
inline bool Contains(const std::string& sRhs) const
|
||||
{
|
||||
return Find(sRhs) == 0;
|
||||
}
|
||||
|
||||
inline bool Contains(const char* pData) const
|
||||
{
|
||||
return Find(pData) == 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
inline int Find(const LSString& sRhs, size_t uiOffset = 0) const
|
||||
{
|
||||
return Find(sRhs.m_pData, uiOffset);
|
||||
}
|
||||
inline int Find(const std::string& sRhs, size_t uiOffset = 0) const
|
||||
{
|
||||
return Find(sRhs.c_str(), uiOffset);
|
||||
}
|
||||
|
||||
inline int Find(const char* pData, size_t uiOffset = 0) const
|
||||
{
|
||||
return Find(pData, uiOffset, StringLength(pData));
|
||||
}
|
||||
|
||||
inline int Find(const LSString& sRhs, size_t uiOffset, size_t uiLength) const
|
||||
{
|
||||
return Find(sRhs.m_pData, uiOffset, uiLength);
|
||||
}
|
||||
inline int Find(const std::string& sRhs, size_t uiOffset, size_t uiLength) const
|
||||
{
|
||||
return Find(sRhs.c_str(), uiOffset, uiLength);
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Logic
|
||||
size_t StringLength(const char* pData) const;
|
||||
|
||||
int Find(const char* pData, size_t uiOffset, size_t uiLength) const;
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
inline char At(size_t uiPos) const
|
||||
{
|
||||
return *(m_pData + uiPos);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
inline size_t Size() const
|
||||
{
|
||||
return m_zSize;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
inline size_t Capacity() const
|
||||
{
|
||||
return m_uiCapacity;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
inline std::string ToStdString() const
|
||||
{
|
||||
return std::string(m_pData);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
inline const char* ToCChar() const
|
||||
{
|
||||
return m_pData;
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
private:
|
||||
void IncreaseCapacity(size_t uiNewLength = 0);
|
||||
|
||||
char* m_pData = nullptr;
|
||||
size_t m_zSize = 0;
|
||||
size_t m_uiCapacity = 0;
|
||||
const float c_uiCapacityIncreaseFactor = 1.5;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
inline LSString operator+(const LSString& sLhs, const LSString& sRhs)
|
||||
{
|
||||
LSString sNew(sLhs);
|
||||
sNew.Append(sRhs);
|
||||
return sNew;
|
||||
}
|
||||
inline LSString operator+(const LSString& sLhs, const char* sRhs)
|
||||
{
|
||||
LSString sNew(sLhs);
|
||||
sNew.Append(sRhs);
|
||||
return sNew;
|
||||
}
|
||||
inline LSString operator+(const char* sLhs, const LSString& sRhs)
|
||||
{
|
||||
LSString sNew(sLhs);
|
||||
sNew.Append(sRhs);
|
||||
return sNew;
|
||||
}
|
131
Software/Framework/src/LSVector.h
Normal file
131
Software/Framework/src/LSVector.h
Normal file
|
@ -0,0 +1,131 @@
|
|||
#pragma once
|
||||
#include "LSFramework.Exports.h"
|
||||
#include "LSMacros.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
template <class T>
|
||||
|
||||
class LSFRAMEWORK_API LSVector
|
||||
{
|
||||
public:
|
||||
|
||||
LSVector()
|
||||
{
|
||||
}
|
||||
|
||||
LSVector(size_t zSize)
|
||||
{
|
||||
m_pData = new T[zSize];
|
||||
m_zCapacity = zSize;
|
||||
}
|
||||
|
||||
LSVector(const LSVector& oRhs)
|
||||
: m_pData(oRhs.m_pData)
|
||||
, m_zSize(oRhs.m_zSize)
|
||||
, m_zCapacity(oRhs.m_zCapacity)
|
||||
{
|
||||
}
|
||||
|
||||
~LSVector()
|
||||
{
|
||||
DELETE_ARRAY(m_pData)
|
||||
}
|
||||
|
||||
T& PushBack(T oNewobj)
|
||||
{
|
||||
return Assign(oNewobj);
|
||||
}
|
||||
|
||||
T& Assign(T oNewobj)
|
||||
{
|
||||
if (m_zSize == m_zCapacity)
|
||||
{
|
||||
m_zCapacity *= c_dCapacityIncreaseFactor;
|
||||
T* pNew = new T[m_zCapacity];
|
||||
memmove(pNew, m_pData, m_zSize);
|
||||
DELETE_ARRAY(m_pData);
|
||||
m_pData = pNew;
|
||||
}
|
||||
m_zSize += 1;
|
||||
m_pData[m_zSize] = oNewobj;
|
||||
return m_pData[m_zSize];
|
||||
}
|
||||
|
||||
T& Insert(T oNewobj, const size_t zPos)
|
||||
{
|
||||
if (zPos == m_zCapacity)
|
||||
{
|
||||
return Assign(oNewobj);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pData[zPos] = oNewobj;
|
||||
return m_pData[zPos];
|
||||
}
|
||||
}
|
||||
|
||||
void PopBack()
|
||||
{
|
||||
Remove(m_zSize);
|
||||
}
|
||||
|
||||
void Remove(const size_t zPos)
|
||||
{
|
||||
memset(m_pData[zPos], 0, sizeof(T));
|
||||
}
|
||||
|
||||
T& At(const size_t zPos)
|
||||
{
|
||||
return m_pData[zPos];
|
||||
}
|
||||
|
||||
void Reserve(const size_t zNewCapacity)
|
||||
{
|
||||
if (zNewCapacity < m_zCapacity) return;
|
||||
T* pOld = m_pData;
|
||||
m_pData = new T[zNewCapacity];
|
||||
memmove_s(m_pData, zNewCapacity, pOld, m_zSize);
|
||||
m_zCapacity = zNewCapacity;
|
||||
DELETE_ARRAY(pOld);
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
DELETE_ARRAY(m_pData)
|
||||
}
|
||||
|
||||
size_t Size() const
|
||||
{
|
||||
return m_zSize;
|
||||
}
|
||||
|
||||
size_t Capacity() const
|
||||
{
|
||||
return m_zCapacity;
|
||||
}
|
||||
|
||||
T* Data() const
|
||||
{
|
||||
return m_pData;
|
||||
}
|
||||
|
||||
LSVector operator=(const LSVector oRhs)
|
||||
{
|
||||
LSVector vTemp();
|
||||
vTemp.m_pData = oRhs.m_pData;
|
||||
}
|
||||
|
||||
T& operator[](const size_t _Pos)
|
||||
{
|
||||
m_pData + _Pos * sizeof(T);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::vector<int> s;
|
||||
T* m_pData = nullptr;
|
||||
size_t m_zSize = 0;
|
||||
size_t m_zCapacity = 0;
|
||||
const float c_dCapacityIncreaseFactor = 1.5;
|
||||
};
|
22
Software/Framework/src/Timer.cpp
Normal file
22
Software/Framework/src/Timer.cpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include "Timer.h"
|
||||
#include <iostream>
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
Timer::Timer(LSString sEndString)
|
||||
: m_StartTimePoint(std::chrono::high_resolution_clock::now())
|
||||
{
|
||||
m_sEndString = sEndString;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
Timer::~Timer()
|
||||
{
|
||||
auto endTimePoint = std::chrono::high_resolution_clock::now();
|
||||
|
||||
auto start = std::chrono::time_point_cast<std::chrono::microseconds>(m_StartTimePoint).time_since_epoch().count();
|
||||
auto end = std::chrono::time_point_cast<std::chrono::microseconds>(endTimePoint).time_since_epoch().count();
|
||||
|
||||
auto duration = end - start;
|
||||
printf("%sMicroseconds: %2d (%.3f ms)\n", m_sEndString.ToCChar(), static_cast<int>(duration), (duration * 0.001));
|
||||
//std::cout << "Duration in Microseconds: " << duration << " (" << duration * 0.001 << " ms)" << std::endl;
|
||||
}
|
16
Software/Framework/src/Timer.h
Normal file
16
Software/Framework/src/Timer.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
#include "LSFramework.Exports.h"
|
||||
#include "LSString.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
class LSFRAMEWORK_API Timer
|
||||
{
|
||||
public:
|
||||
Timer(LSString sEndString = "");
|
||||
|
||||
~Timer(void);
|
||||
private:
|
||||
LSString m_sEndString;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> m_StartTimePoint;
|
||||
};
|
113
Software/Framework/src/main.cpp
Normal file
113
Software/Framework/src/main.cpp
Normal file
File diff suppressed because one or more lines are too long
50
Software/Project.conf.cmake
Normal file
50
Software/Project.conf.cmake
Normal file
|
@ -0,0 +1,50 @@
|
|||
###########################################################################################
|
||||
#
|
||||
# (c) Technical Software Engineering Plazotta 2022
|
||||
#
|
||||
# CMAKE project configuration file
|
||||
#
|
||||
# -- DO NOT EDIT, will be generated automatically --
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------
|
||||
# Define user specific elements for all tools and components
|
||||
#
|
||||
IF(WIN32)
|
||||
set (TSEP_STORAGE_PATH "E:/TsepStorage")
|
||||
ELSE()
|
||||
set (TSEP_STORAGE_PATH /opt/tsep-storage)
|
||||
ENDIF()
|
||||
set (TSEP_PRODUCT_GROUP "Development")
|
||||
set (TSEP_PRODUCT_NAME "LSFramework")
|
||||
set (TSEP_PRODUCT_DESCRIPTION "TSEP Core Framework")
|
||||
set (TSEP_PRODUCT_VERSION "1,5,100")
|
||||
set (TSEP_VERSION "1.5.100")
|
||||
set (TSEP_VERSION_MAJOR 1)
|
||||
set (TSEP_VERSION_MINOR 5)
|
||||
set (TSEP_VERSION_PATCH 100)
|
||||
set (TSEP_NEXUS_VERSION "01.05.100")
|
||||
set (TSEP_UPDATE_IN_NEXUS "true")
|
||||
set (TSEP_COPYRIGHT_STRING "Copyright Technical Software Engineering Plazotta 2022")
|
||||
set (TSEP_COMPANY_LONGNAME "Technical Software Engineering Plazotta")
|
||||
set (TSEP_NEXUS_URL "https://srv-nexus-3.tsep.local/repository")
|
||||
set (TSEP_NEXUS_GUID "53ec8373-e298-31ed-bd2f-c21204d48a32")
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------
|
||||
# Define component specific private elements
|
||||
#
|
||||
set (TSEP_PROJECT_CMAKE "${TSEP_STORAGE_PATH}/CMake/CMake.1.5.1")
|
||||
set (TSEP_PROJECT_GOOGLE.TEST "${TSEP_STORAGE_PATH}/Google.Test/Google.Test.1.10.1")
|
||||
set (TSEP_PROJECT_INTIME "${TSEP_STORAGE_PATH}/INtime/INtime.6.4.5")
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------
|
||||
# Include the cmake definition for basic compiler and os defines
|
||||
#
|
||||
include(${TSEP_PROJECT_CMAKE}/CMakeCore.cmake)
|
||||
#
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------
|
||||
# Define component specific public elements
|
||||
#
|
||||
set (TSEP_PROJECT_FRAMEWORK.CORE "${TSEP_STORAGE_PATH}/Framework.Core/Framework.Core.1.5.100/bin/${TSEP_CMAKE_GENERATOR}/cmake")
|
||||
|
25
Software/VSGenerateProject.cmd
Normal file
25
Software/VSGenerateProject.cmd
Normal file
|
@ -0,0 +1,25 @@
|
|||
@echo off
|
||||
setlocal
|
||||
|
||||
rem define build parameters
|
||||
set ARCHITECTURE=x64
|
||||
set VISUAL_STUDIO=msvc2019
|
||||
set GENERATOR=Visual Studio 16 2019
|
||||
|
||||
rem concatenate build directory
|
||||
set BUILDRESULTS=%~dp0\..\BuildResults\%VISUAL_STUDIO%_%ARCHITECTURE%
|
||||
|
||||
rem create build directory and push into it
|
||||
if not exist %BUILDRESULTS% mkdir %BUILDRESULTS%
|
||||
if not exist %BUILDRESULTS%\Debug\bin mkdir %BUILDRESULTS%\Debug\bin
|
||||
if not exist %BUILDRESULTS%\Release\bin mkdir %BUILDRESULTS%\Release\bin
|
||||
|
||||
pushd %BUILDRESULTS%
|
||||
|
||||
rem run CMake to build the solution
|
||||
echo running CMake...
|
||||
cmake.exe -G "%GENERATOR%" ../../Software
|
||||
|
||||
popd
|
||||
|
||||
pause
|
Loading…
Add table
Add a link
Reference in a new issue