created project with cmake

This commit is contained in:
Luis Stanglmeier 2022-06-23 13:44:39 +02:00
parent c4b3d8ac5f
commit 5f6abf300e
54 changed files with 412 additions and 310 deletions

View file

View 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;

View 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
};

View file

View 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__

View 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;
};

View 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;
};

View 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;\
}

View 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;
}

View 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;
}

View 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;
};

View 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;
}

View 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;
};

File diff suppressed because one or more lines are too long