initial public release

This commit is contained in:
Mamadou Babaei
2022-11-02 22:43:14 +01:00
commit ff02526c05
4222 changed files with 85051 additions and 0 deletions
@@ -0,0 +1,36 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2022 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
#include "SGUtils/SGArrayUtils.h"
@@ -0,0 +1,36 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2022 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
#include "SGUtils/SGEnumUtils.h"
@@ -0,0 +1,40 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2022 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
#include "SenseGloveUtils.h"
#include "Modules/ModuleManager.h"
#include "SenseGloveUtilsModule.h"
IMPLEMENT_MODULE(FSenseGloveUtilsModule, SenseGloveUtils)
@@ -0,0 +1,38 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2022 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
#pragma once
#include "CoreMinimal.h"
@@ -0,0 +1,61 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2022 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
#include "SenseGloveUtilsModule.h"
#include "SGLog/SGLog.h"
#define LOCTEXT_NAMESPACE "FSenseGloveUtilsModule"
void FSenseGloveUtilsModule::StartupModule()
{
SGLOG("Starting up SenseGloveUtils module...");
}
void FSenseGloveUtilsModule::PreUnloadCallback()
{
SGLOG("Unloading SenseGloveUtils module...");
}
void FSenseGloveUtilsModule::PostLoadCallback()
{
SGLOG("Loading of SenseGloveUtils module has succeeded!");
}
void FSenseGloveUtilsModule::ShutdownModule()
{
SGLOG("Shutting down SenseGloveUtils module...");
}
#undef LOCTEXT_NAMESPACE
@@ -0,0 +1,51 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2022 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
#pragma once
#include "Modules/ModuleInterface.h"
#define LOCTEXT_NAMESPACE "SenseGloveUtils"
class FSenseGloveUtilsModule : public IModuleInterface
{
public:
virtual void StartupModule() override;
virtual void PreUnloadCallback() override;
virtual void PostLoadCallback() override;
virtual void ShutdownModule() override;
};
#undef LOCTEXT_NAMESPACE
@@ -0,0 +1,450 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2022 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED To THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ToRT OR OTHERWISE, ARISING From,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
#pragma once
#include <vector>
#include "Containers/Array.h"
#include "Templates/UnrealTemplate.h"
class SENSEGLOVEUTILS_API FSGArrayUtils final
{
public:
template<typename T>
static FORCEINLINE TArray<T> FromStdVector(const std::vector<T>& Vector)
{
TArray<T> Array(&Vector[0], Vector.size());
return MoveTemp(Array);
}
/// NOTE
/// std::vector<bool> is a non conforming container. Since it packs bools to be stored in one bit,
/// it cannot provide a bool reference. Thus, FSGArrayUtils::FromStdVector<bool>() cannot be used.
/// Hence, the specialization.
static TArray<bool> FromStdVector(const std::vector<bool>& Vector)
{
TArray<bool> Array;
for (const bool bValue: Vector)
{
Array.Add(bValue);
}
return MoveTemp(Array);
}
template<typename T>
static FORCEINLINE TArray<TArray<T>> FromStdVector(const std::vector<std::vector<T>>& Vector)
{
TArray<TArray<T>> Array;
for (const std::vector<T>& InnerVector: Vector)
{
TArray<T> InnerArray{FromStdVector<T>(InnerVector)};
Array.Add(MoveTemp(InnerArray));
}
return MoveTemp(Array);
}
template<typename T1, typename T2>
static TArray<T2> FromStdVector(const std::vector<T1>& Vector)
{
TArray<T2> Array;
for (const T1& T1Element: Vector)
{
T2 T2Element(T1Element);
Array.Add(MoveTemp(T2Element));
}
return MoveTemp(Array);
}
template<typename T1, typename T2>
static TArray<TArray<T2>> FromStdVector(const std::vector<std::vector<T1>>& Vector)
{
TArray<TArray<T2>> Array;
for (const std::vector<T1>& InnerVector: Vector)
{
TArray<T2> InnerArray{FromStdVector<T1, T2>(InnerVector)};
Array.Add(MoveTemp(InnerArray));
}
return MoveTemp(Array);
}
template<typename T1, typename T2, typename IntermediateImpl, T2(IntermediateImpl::*ToT2TypeMethod)() const>
static TArray<T2> FromStdVector(const std::vector<T1>& Vector)
{
TArray<T2> Array;
for (const T1& T1Element: Vector)
{
IntermediateImpl ImplElement(T1Element);
T2 T2Element((ImplElement.*ToT2TypeMethod)());
Array.Add(MoveTemp(T2Element));
}
return MoveTemp(Array);
}
template<typename T1, typename T2, typename IntermediateImpl, T2(IntermediateImpl::*ToT2TypeMethod)() const>
static TArray<TArray<T2>> FromStdVector(const std::vector<std::vector<T1>>& Vector)
{
TArray<TArray<T2>> Array;
for (const std::vector<T1>& InnerVector: Vector)
{
TArray<T2> InnerArray{FromStdVector<T1, T2, IntermediateImpl, ToT2TypeMethod>(InnerVector)};
Array.Add(MoveTemp(InnerArray));
}
return MoveTemp(Array);
}
template<typename T>
static FORCEINLINE std::vector<T> ToStdVector(const TArray<T>& Array)
{
std::vector<T> Vector(&Array[0], &Array[0] + Array.Num());
return MoveTemp(Vector);
}
template<typename T>
static FORCEINLINE std::vector<std::vector<T>> ToStdVector(const TArray<TArray<T>>& Array)
{
std::vector<std::vector<T>> Vector;
for (const TArray<T>& InnerArray: Array)
{
std::vector<T> InnerVector{ToStdVector<T>(InnerArray)};
Vector.emplace_back(MoveTemp(InnerVector));
}
return MoveTemp(Vector);
}
template<typename T1, typename T2, const T2&(T1::*ToUnderlyingTypeMethod)() const>
static std::vector<T2> ToStdVector(const TArray<T1>& Array)
{
std::vector<T2> Vector;
for (const T1& T1Element: Array)
{
T2 T2Element((T1Element.*ToUnderlyingTypeMethod)());
Vector.emplace_back(MoveTemp(T2Element));
}
return MoveTemp(Vector);
}
template<typename T1, typename T2, const T2&(T1::*ToUnderlyingTypeMethod)() const>
static std::vector<std::vector<T2>> ToStdVector(const TArray<TArray<T1>>& Array)
{
std::vector<std::vector<T2>> Vector;
for (const TArray<T1>& InnerArray: Array)
{
std::vector<T2> InnerVector{ToStdVector<T1, T2, ToUnderlyingTypeMethod>(InnerArray)};
Vector.emplace_back(MoveTemp(InnerVector));
}
return MoveTemp(Vector);
}
template<typename T1, typename T2, typename IntermediateImpl,
const T2&(IntermediateImpl::*ToUnderlyingTypeMethod)() const>
static std::vector<T2> ToStdVector(const TArray<T1>& Array)
{
std::vector<T2> Vector;
for (const T1& T1Element: Array)
{
IntermediateImpl ImplElement(T1Element);
T2 T2Element((ImplElement.*ToUnderlyingTypeMethod)());
Vector.emplace_back(MoveTemp(T2Element));
}
return MoveTemp(Vector);
}
template<typename T1, typename T2, typename IntermediateImpl,
const T2&(IntermediateImpl::*ToUnderlyingTypeMethod)() const>
static std::vector<std::vector<T2>> ToStdVector(const TArray<TArray<T1>>& Array)
{
std::vector<std::vector<T2>> Vector;
for (const TArray<T1>& InnerArray: Array)
{
std::vector<T2> InnerVector{ToStdVector<T1, T2, IntermediateImpl, ToUnderlyingTypeMethod>(InnerArray)};
Vector.emplace_back(MoveTemp(InnerVector));
}
return MoveTemp(Vector);
}
template<typename T1, typename T2>
static TArray<T2> FromImplType(const TArray<T1>& ImplArray)
{
TArray<T2> Array;
for (const T1& T1Element: ImplArray)
{
T2 T2Element(T1Element);
Array.Add(MoveTemp(T2Element));
}
return MoveTemp(Array);
}
template<typename T1, typename T2, T2*(*NewObjectMethod)(UObject*, const T1&)>
static TArray<T2*> FromImplType(UObject* Outer, const TArray<T1>& ImplArray)
{
TArray<T2*> Array;
for (const T1& T1Element: ImplArray)
{
T2* T2Element(NewObjectMethod(Outer, T1Element));
Array.Add(MoveTemp(T2Element));
}
return MoveTemp(Array);
}
template<typename T1, typename T2>
static TArray<TArray<T2>> FromImplType(const TArray<TArray<T1>>& ImplArray)
{
TArray<TArray<T2>> Array;
for (const TArray<T1>& InnerImplArray: ImplArray)
{
TArray<T2> InnerArray{FromImplType<T1, T2>(InnerImplArray)};
Array.Add(MoveTemp(InnerArray));
}
return MoveTemp(Array);
}
template<typename T1, typename T2, T2*(*NewObjectMethod)(UObject*, const T1&)>
static TArray<TArray<T2*>> FromImplType(UObject* Outer, const TArray<TArray<T1>>& ImplArray)
{
TArray<TArray<T2*>> Array;
for (const TArray<T1>& InnerImplArray: ImplArray)
{
TArray<T2*> InnerArray{FromImplType<T1, T2, NewObjectMethod>(Outer, InnerImplArray)};
Array.Add(MoveTemp(InnerArray));
}
return MoveTemp(Array);
}
template<typename T1, typename T2, typename S>
static TArray<S> FromImplType(const TArray<TArray<T1>>& ImplArray)
{
TArray<S> Array;
for (const TArray<T1>& InnerImplArray: ImplArray)
{
TArray<T2> InnerArray{FromImplType<T1, T2>(InnerImplArray)};
S InnerArrayContainer{MoveTemp(InnerArray)};
Array.Add(MoveTemp(InnerArrayContainer));
}
return MoveTemp(Array);
}
template<typename T1, typename T2, typename S, T2*(*NewObjectMethod)(UObject*, const T1&)>
static TArray<S> FromImplType(UObject* Outer, const TArray<TArray<T1>>& ImplArray)
{
TArray<S> Array;
for (const TArray<T1>& InnerImplArray: ImplArray)
{
TArray<T2*> InnerArray{FromImplType<T1, T2, NewObjectMethod>(Outer, InnerImplArray)};
S InnerArrayContainer{MoveTemp(InnerArray)};
Array.Add(MoveTemp(InnerArrayContainer));
}
return MoveTemp(Array);
}
template<typename T1, typename T2, typename S>
static TArray<S> FromImplType(const TArray<TArray<T1*>>& ImplArray)
{
TArray<S> Array;
for (const TArray<T1>& InnerImplArray: ImplArray)
{
TArray<T2> InnerArray{FromImplType<T1, T2>(InnerImplArray)};
S InnerArrayContainer{MoveTemp(InnerArray)};
Array.Add(MoveTemp(InnerArrayContainer));
}
return MoveTemp(Array);
}
template<typename T1, typename T2, const T2&(T1::*ToUnderlyingTypeMethod)() const>
static TArray<T2> ToImplType(const TArray<T1>& Array)
{
TArray<T2> ImplArray;
for (const T1& T1Element: Array)
{
T2 T2Element((T1Element.*ToUnderlyingTypeMethod)());
ImplArray.Add(MoveTemp(T2Element));
}
return MoveTemp(ImplArray);
}
template<typename T1, typename T2, const T2&(T1::*ToUnderlyingTypeMethod)() const>
static TArray<T2> ToImplType(const TArray<T1*>& Array)
{
TArray<T2> ImplArray;
for (const T1* T1Element: Array)
{
T2 T2Element((T1Element->*ToUnderlyingTypeMethod)());
ImplArray.Add(MoveTemp(T2Element));
}
return MoveTemp(ImplArray);
}
template<typename T1, typename T2, const T2&(T1::*ToUnderlyingTypeMethod)() const>
static TArray<TArray<T2>> ToImplType(const TArray<TArray<T1>>& Array)
{
TArray<TArray<T2>> ImplArray;
for (const TArray<T1>& InnerArray: Array)
{
TArray<T2> InnerImplArray{ToImplType<T1, T2, ToUnderlyingTypeMethod>(InnerArray)};
ImplArray.Add(MoveTemp(InnerImplArray));
}
return MoveTemp(ImplArray);
}
template<typename T1, typename T2, const T2&(T1::*ToUnderlyingTypeMethod)() const>
static TArray<TArray<T2>> ToImplType(const TArray<TArray<T1*>>& Array)
{
TArray<TArray<T2>> ImplArray;
for (const TArray<T1*>& InnerArray: Array)
{
TArray<T2> InnerImplArray{ToImplType<T1, T2, ToUnderlyingTypeMethod>(InnerArray)};
ImplArray.Add(MoveTemp(InnerImplArray));
}
return MoveTemp(ImplArray);
}
template<typename T1, typename T2, const T2&(T1::*ToUnderlyingTypeMethod)() const, typename S, TArray<T1> S::*InnerArray>
static TArray<TArray<T2>> ToImplType(const TArray<S>& Array)
{
TArray<TArray<T2>> ImplArray;
for (const S& InnerArrayContainer: Array)
{
TArray<T2> InnerImplArray{ToImplType<T1, T2, ToUnderlyingTypeMethod>(InnerArrayContainer.*InnerArray)};
ImplArray.Add(MoveTemp(InnerImplArray));
}
return MoveTemp(ImplArray);
}
template<typename T1, typename T2, const T2&(T1::*ToUnderlyingTypeMethod)() const, typename S, TArray<T1*> S::*InnerArray>
static TArray<TArray<T2>> ToImplType(const TArray<S>& Array)
{
TArray<TArray<T2>> ImplArray;
for (const S& InnerArrayContainer: Array)
{
TArray<T2> InnerImplArray{ToImplType<T1, T2, ToUnderlyingTypeMethod>(InnerArrayContainer.*InnerArray)};
ImplArray.Add(MoveTemp(InnerImplArray));
}
return MoveTemp(ImplArray);
}
template<typename T, typename S, TArray<T> S::*InnerArray>
static TArray<TArray<T>> FromBPNestedArray(const TArray<S>& BPNestedArray)
{
TArray<TArray<T>> NestedArray;
for (const S& BPInnerArrayContainer: BPNestedArray)
{
NestedArray.Add(BPInnerArrayContainer.*InnerArray);
}
return MoveTemp(NestedArray);
}
template<typename T, typename S>
static TArray<S> ToBPNestedArray(const TArray<TArray<T>>& NestedArray)
{
TArray<S> BPNestedArray;
for (const TArray<T>& InnerArray: NestedArray)
{
S BPInnerArrayContainer{InnerArray};
BPNestedArray.Add(MoveTemp(BPInnerArrayContainer));
}
return MoveTemp(BPNestedArray);
}
template<typename T, typename S>
static TArray<S> ToBPNestedArray(const TArray<TArray<T*>>& NestedArray)
{
TArray<S> BPNestedArray;
for (const TArray<T*>& InnerArray: NestedArray)
{
S BPInnerArrayContainer{InnerArray};
BPNestedArray.Add(MoveTemp(BPInnerArrayContainer));
}
return MoveTemp(BPNestedArray);
}
public:
FSGArrayUtils() = delete;
virtual ~FSGArrayUtils() = delete;
};
@@ -0,0 +1,68 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2022 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
#pragma once
#include "Containers/UnrealString.h"
#include "Misc/AssertionMacros.h"
#include "Templates/UnrealTemplate.h"
#include "UObject/Class.h"
#include "UObject/Object.h"
#include "UObject/Package.h"
#include "UObject/ObjectMacros.h"
class SENSEGLOVEUTILS_API SGEnumUtils
{
public:
template<typename E>
static FORCEINLINE FString ValueToName(const FString& Enum, const E Value)
{
const UEnum* EnumPtr = FindObject<UEnum>(ANY_PACKAGE, *Enum, true);
if (!ensureAlwaysMsgf(EnumPtr, TEXT("No such enum exists!"))) {
return FString("None");
}
return EnumPtr->GetNameByValue(StaticCast<int64>(Value)).ToString();
}
template <typename E>
static FORCEINLINE E NameToValue(const FString& Enum, const FString& Name)
{
UEnum* EnumPtr = FindObject<UEnum>(ANY_PACKAGE, *Enum, true);
if (!ensureAlwaysMsgf(EnumPtr, TEXT("No such enum exists!"))) {
return StaticCast<E>(0);
}
return StaticCast<E>(EnumPtr->GetValueByName(FName(*Name)));
}
};
@@ -0,0 +1,60 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2022 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
using System;
using UnrealBuildTool;
public class SenseGloveUtils : ModuleRules
{
public SenseGloveUtils(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
"CoreUObject",
"SenseGloveLog",
}
);
}
}