Compare commits
10 Commits
5a38f9f36d
...
_old
| Author | SHA1 | Date | |
|---|---|---|---|
| 38b6137c38 | |||
| 1118ec3205 | |||
| a7abdbae57 | |||
| c1cad88224 | |||
| cdc44137e8 | |||
| 2498e7d6e3 | |||
| 3add03dcc0 | |||
| f7d4b28744 | |||
| 9f9991494e | |||
| 6c3090f3c6 |
Binary file not shown.
Binary file not shown.
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@ -1,5 +1,6 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"*.rml": "html",
|
||||
"stdexcept": "cpp",
|
||||
"chrono": "cpp",
|
||||
"forward_list": "cpp",
|
||||
@ -67,6 +68,11 @@
|
||||
"iostream": "cpp",
|
||||
"map": "cpp",
|
||||
"ostream": "cpp",
|
||||
"xtree": "cpp"
|
||||
"xtree": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"coroutine": "cpp",
|
||||
"resumable": "cpp",
|
||||
"future": "cpp",
|
||||
"mutex": "cpp"
|
||||
}
|
||||
}
|
||||
@ -3,3 +3,7 @@ add_library(IACore STATIC imp/cpp/dummy.cpp)
|
||||
|
||||
target_include_directories(IACore PUBLIC inc/hpp imp/inl)
|
||||
target_compile_definitions(IACore PUBLIC _CRT_SECURE_NO_WARNINGS)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||
target_link_libraries(IACore PUBLIC dl)
|
||||
endif()
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "interface/StreamReader.interface.inl"
|
||||
#include "Interface/StreamReader.interface.inl"
|
||||
|
||||
namespace ia
|
||||
{
|
||||
|
||||
@ -300,6 +300,7 @@ namespace ia
|
||||
{
|
||||
const auto did_reallocate = reserve(newCount);
|
||||
for(; Base::m_count < newCount; Base::m_count++) Base::m_allocator.construct(&Base::m_data[Base::m_count]);
|
||||
Base::m_count = newCount;
|
||||
return did_reallocate;
|
||||
}
|
||||
|
||||
|
||||
@ -19,11 +19,18 @@
|
||||
#include <IACore/Base.hpp>
|
||||
#include <memory>
|
||||
|
||||
#define REF_PTR_CLASS \
|
||||
template<typename _value_type, typename... Args> friend INLINE RefPtr<_value_type> MakeRefPtr(Args &&...args) \
|
||||
{ \
|
||||
return std::make_shared<_value_type>(std::forward<Args>(args)...); \
|
||||
}
|
||||
|
||||
namespace ia
|
||||
{
|
||||
template<typename _value_type>
|
||||
using RefPtr = std::shared_ptr<_value_type>;
|
||||
template<typename _value_type> using RefPtr = std::shared_ptr<_value_type>;
|
||||
|
||||
template<typename _value_type, typename... Args>
|
||||
INLINE RefPtr<_value_type> MakeRefPtr(Args... args) { return std::make_shared<_value_type>(args...); }
|
||||
}
|
||||
template<typename _value_type, typename... Args> INLINE RefPtr<_value_type> MakeRefPtr(Args &&...args)
|
||||
{
|
||||
return std::make_shared<_value_type>(std::forward<Args>(args)...);
|
||||
}
|
||||
} // namespace ia
|
||||
|
||||
0
Src/IACore/imp/inl/IACore/platform/android/.gitkeep
Normal file
0
Src/IACore/imp/inl/IACore/platform/android/.gitkeep
Normal file
25
Src/IACore/imp/inl/IACore/platform/environment.inl
Normal file
25
Src/IACore/imp/inl/IACore/platform/environment.inl
Normal file
@ -0,0 +1,25 @@
|
||||
// IACore-OSS; The Core Library for All IA Open Source Projects
|
||||
// Copyright (C) 2024 IAS (ias@iasoft.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "platform.inl"
|
||||
|
||||
#if (defined(IA_CORE_PLATFORM_FEATUES) && (IA_CORE_PLATFORM_FEATUES > 0))
|
||||
#if (defined(IA_PLATFORM_WIN64) && (IA_PLATFORM_WIN64 > 0))
|
||||
#include "win/environment.inl"
|
||||
#endif
|
||||
#endif
|
||||
@ -0,0 +1,29 @@
|
||||
// IACore-OSS; The Core Library for All IA Open Source Projects
|
||||
// Copyright (C) 2024 IAS (ias@iasoft.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <IACore/String.hpp>
|
||||
|
||||
namespace ia
|
||||
{
|
||||
class Environment
|
||||
{
|
||||
public:
|
||||
INLINE STATIC String GetVar(IN CONST String& name);
|
||||
INLINE STATIC BOOL SetVar(IN CONST String& name, IN CONST String& value);
|
||||
};
|
||||
}
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <IACore/base.hpp>
|
||||
#include <IACore/Base.hpp>
|
||||
|
||||
namespace ia
|
||||
{
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
// IACore-OSS; The Core Library for All IA Open Source Projects
|
||||
// Copyright (C) 2024 IAS (ias@iasoft.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <IACore/String.hpp>
|
||||
|
||||
namespace ia
|
||||
{
|
||||
class SubProcess
|
||||
{
|
||||
public:
|
||||
INLINE SubProcess(IN CONST String &path);
|
||||
INLINE ~SubProcess();
|
||||
|
||||
INLINE INT32 Launch(IN CONST String &args, IN Function<VOID(CONST String &)> onOutputLineCallback);
|
||||
|
||||
private:
|
||||
CONST String m_path;
|
||||
};
|
||||
} // namespace ia
|
||||
0
Src/IACore/imp/inl/IACore/platform/ios/.gitkeep
Normal file
0
Src/IACore/imp/inl/IACore/platform/ios/.gitkeep
Normal file
0
Src/IACore/imp/inl/IACore/platform/linux/.gitkeep
Normal file
0
Src/IACore/imp/inl/IACore/platform/linux/.gitkeep
Normal file
0
Src/IACore/imp/inl/IACore/platform/macos/.gitkeep
Normal file
0
Src/IACore/imp/inl/IACore/platform/macos/.gitkeep
Normal file
@ -133,3 +133,10 @@ namespace ia
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
|
||||
}
|
||||
}
|
||||
|
||||
#if (defined(IA_PLATFORM_WIN64) && (IA_PLATFORM_WIN64 > 0))
|
||||
#define IA_CORE_PLATFORM_FEATUES 1
|
||||
#else
|
||||
#define IA_CORE_PLATFORM_FEATUES 0
|
||||
#warning "IACore Unsupported Platform: Platform specific features will be disabled"
|
||||
#endif
|
||||
25
Src/IACore/imp/inl/IACore/platform/process.inl
Normal file
25
Src/IACore/imp/inl/IACore/platform/process.inl
Normal file
@ -0,0 +1,25 @@
|
||||
// IACore-OSS; The Core Library for All IA Open Source Projects
|
||||
// Copyright (C) 2024 IAS (ias@iasoft.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "platform.inl"
|
||||
|
||||
#if (defined(IA_CORE_PLATFORM_FEATUES) && (IA_CORE_PLATFORM_FEATUES > 0))
|
||||
#if (defined(IA_PLATFORM_WIN64) && (IA_PLATFORM_WIN64 > 0))
|
||||
#include "win/process.inl"
|
||||
#endif
|
||||
#endif
|
||||
25
Src/IACore/imp/inl/IACore/platform/win/common.inl
Normal file
25
Src/IACore/imp/inl/IACore/platform/win/common.inl
Normal file
@ -0,0 +1,25 @@
|
||||
// IACore-OSS; The Core Library for All IA Open Source Projects
|
||||
// Copyright (C) 2024 IAS (ias@iasoft.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
namespace ia
|
||||
{
|
||||
|
||||
}
|
||||
40
Src/IACore/imp/inl/IACore/platform/win/environment.inl
Normal file
40
Src/IACore/imp/inl/IACore/platform/win/environment.inl
Normal file
@ -0,0 +1,40 @@
|
||||
// IACore-OSS; The Core Library for All IA Open Source Projects
|
||||
// Copyright (C) 2024 IAS (ias@iasoft.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../interface/environment.interface.inl"
|
||||
#include "common.inl"
|
||||
|
||||
namespace ia
|
||||
{
|
||||
String Environment::GetVar(IN CONST String &name)
|
||||
{
|
||||
const auto l = GetEnvironmentVariableA(name.c_str(), nullptr, 0);
|
||||
if (!l)
|
||||
return "";
|
||||
String result;
|
||||
result.resize(l);
|
||||
GetEnvironmentVariableA(name.c_str(), result.data(), l);
|
||||
result.back() = '\0';
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOL Environment::SetVar(IN CONST String &name, IN CONST String &value)
|
||||
{
|
||||
return SetEnvironmentVariableA(name.c_str(), value.c_str());
|
||||
}
|
||||
} // namespace ia
|
||||
137
Src/IACore/imp/inl/IACore/platform/win/process.inl
Normal file
137
Src/IACore/imp/inl/IACore/platform/win/process.inl
Normal file
@ -0,0 +1,137 @@
|
||||
// IACore-OSS; The Core Library for All IA Open Source Projects
|
||||
// Copyright (C) 2024 IAS (ias@iasoft.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../interface/process.interface.inl"
|
||||
#include "common.inl"
|
||||
|
||||
#include <IACore/Exception.hpp>
|
||||
|
||||
namespace ia
|
||||
{
|
||||
SubProcess::SubProcess(IN CONST String &path) : m_path(path)
|
||||
{
|
||||
}
|
||||
|
||||
SubProcess::~SubProcess()
|
||||
{
|
||||
}
|
||||
|
||||
INT32 SubProcess::Launch(IN CONST String &args, IN Function<VOID(CONST String &)> onOutputLineCallback)
|
||||
{
|
||||
String szCmdline = BuildString(m_path, " ", args);
|
||||
|
||||
PROCESS_INFORMATION piProcInfo;
|
||||
STARTUPINFOA siStartInfo;
|
||||
BOOL bSuccess = FALSE;
|
||||
ZeroMemory(&piProcInfo, sizeof(PROCESS_INFORMATION));
|
||||
|
||||
HANDLE hRdStdIn{};
|
||||
HANDLE hWrStdIn{};
|
||||
HANDLE hRdStdOut{};
|
||||
HANDLE hWrStdOut{};
|
||||
|
||||
SECURITY_ATTRIBUTES saAttr;
|
||||
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
saAttr.bInheritHandle = TRUE;
|
||||
saAttr.lpSecurityDescriptor = NULL;
|
||||
if (!CreatePipe(&hRdStdIn, &hWrStdIn, &saAttr, 0))
|
||||
THROW_UNKNOWN("Failed to create a win32 pipe");
|
||||
if (!SetHandleInformation(hWrStdIn, HANDLE_FLAG_INHERIT, 0))
|
||||
THROW_UNKNOWN("Failed to update a win32 pipe");
|
||||
if (!CreatePipe(&hRdStdOut, &hWrStdOut, &saAttr, 0))
|
||||
THROW_UNKNOWN("Failed to create a win32 pipe");
|
||||
if (!SetHandleInformation(hRdStdOut, HANDLE_FLAG_INHERIT, 0))
|
||||
THROW_UNKNOWN("Failed to update a win32 pipe");
|
||||
|
||||
ZeroMemory(&siStartInfo, sizeof(STARTUPINFOA));
|
||||
siStartInfo.cb = sizeof(STARTUPINFOA);
|
||||
siStartInfo.hStdError = hWrStdOut;
|
||||
siStartInfo.hStdOutput = hWrStdOut;
|
||||
siStartInfo.hStdInput = hRdStdIn;
|
||||
siStartInfo.dwFlags |= STARTF_USESTDHANDLES;
|
||||
|
||||
bSuccess = CreateProcessA(NULL,
|
||||
szCmdline.data(), // command line
|
||||
NULL, // process security attributes
|
||||
NULL, // primary thread security attributes
|
||||
TRUE, // handles are inherited
|
||||
0, // creation flags
|
||||
NULL, // use parent's environment
|
||||
NULL, // use parent's current directory
|
||||
&siStartInfo, // STARTUPINFO pointer
|
||||
&piProcInfo); // receives PROCESS_INFORMATION
|
||||
|
||||
if (!bSuccess)
|
||||
THROW_UNKNOWN("Couldn't spawn the child process \"", m_path, "\"");
|
||||
else
|
||||
{
|
||||
CloseHandle(piProcInfo.hProcess);
|
||||
CloseHandle(piProcInfo.hThread);
|
||||
|
||||
CloseHandle(hWrStdOut);
|
||||
CloseHandle(hRdStdIn);
|
||||
}
|
||||
|
||||
CloseHandle(hWrStdIn);
|
||||
|
||||
DWORD exitCode{};
|
||||
while (true)
|
||||
{
|
||||
GetExitCodeProcess(piProcInfo.hProcess, &exitCode);
|
||||
if (exitCode != STILL_ACTIVE)
|
||||
break;
|
||||
}
|
||||
|
||||
Vector<CHAR> currentLine;
|
||||
CHAR readBuffer[1024];
|
||||
while (true)
|
||||
{
|
||||
DWORD readSize;
|
||||
const auto success = ReadFile(hRdStdOut, readBuffer, sizeof(readBuffer), &readSize, NULL);
|
||||
if ((!success) || (!readSize))
|
||||
break;
|
||||
for (DWORD i = 0; i < readSize; i++)
|
||||
{
|
||||
if (readBuffer[i] == '\n')
|
||||
{
|
||||
String result;
|
||||
result.resize(currentLine.size() + 1);
|
||||
memcpy(result.data(), currentLine.data(), currentLine.size());
|
||||
result[currentLine.size()] = '\0';
|
||||
currentLine.reset();
|
||||
onOutputLineCallback(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentLine.append(readBuffer[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentLine.size())
|
||||
{
|
||||
String result;
|
||||
result.resize(currentLine.size() + 1);
|
||||
memcpy(result.data(), currentLine.data(), currentLine.size());
|
||||
result[currentLine.size()] = '\0';
|
||||
onOutputLineCallback(result);
|
||||
}
|
||||
|
||||
return exitCode;
|
||||
}
|
||||
} // namespace ia
|
||||
@ -19,13 +19,14 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <new>
|
||||
#include <cstddef>
|
||||
#include <concepts>
|
||||
#include <functional>
|
||||
#include <assert.h>
|
||||
#include <type_traits>
|
||||
#include <concepts>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <initializer_list>
|
||||
#include <new>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
#define IAC_SEC_LEVEL(v) (IACORE_SECURITY_LEVEL >= v)
|
||||
|
||||
@ -66,12 +67,12 @@
|
||||
|
||||
#define INLINE inline
|
||||
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
|
||||
#define ALWAYS_INLINE __attribute__((always_inline)) inline
|
||||
#define ALWAYS_INLINE __attribute__((always_inline)) inline
|
||||
#elif defined(_MSC_VER)
|
||||
#define ALWAYS_INLINE __forceinline
|
||||
#define ALWAYS_INLINE __forceinline
|
||||
#endif
|
||||
|
||||
#define UNUSED(v) ((void)v);
|
||||
#define UNUSED(v) ((void) v);
|
||||
|
||||
#define NO_DISCARD(s) [[nodiscard(s)]]
|
||||
|
||||
@ -110,16 +111,17 @@
|
||||
|
||||
#define C_DECL(f) EXTERN "C" f
|
||||
|
||||
#define CAST(v, t) ((t)v)
|
||||
#define CAST(v, t) ((t) v)
|
||||
|
||||
#define ALIAS_FUNCTION(alias, function) template <typename... Args> \
|
||||
auto alias(Args&&... args) -> decltype(f(std::forward<Args>(args)...)) \
|
||||
#define ALIAS_FUNCTION(alias, function) \
|
||||
template<typename... Args> auto alias(Args &&...args) -> decltype(f(std::forward<Args>(args)...)) \
|
||||
{ \
|
||||
return function(std::forward<Args>(args)...); \
|
||||
}
|
||||
|
||||
#define ALIAS_TEMPLATE_FUNCTION(t, alias, function) template <typename t, typename... Args> \
|
||||
auto alias(Args&&... args) -> decltype(function<t>(std::forward<Args>(args)...)) \
|
||||
#define ALIAS_TEMPLATE_FUNCTION(t, alias, function) \
|
||||
template<typename t, typename... Args> \
|
||||
auto alias(Args &&...args) -> decltype(function<t>(std::forward<Args>(args)...)) \
|
||||
{ \
|
||||
return function<t>(std::forward<Args>(args)...); \
|
||||
}
|
||||
@ -150,18 +152,29 @@
|
||||
#define IA_MAX_STRING_LENGTH (IA_MAX_POSSIBLE_SIZE >> 8)
|
||||
|
||||
#define IA_VERSION_TYPE UINT64
|
||||
#define IA_MAKE_VERSION(major, minor, patch) ((static_cast<UINT64>(major) & 0xFFFFFF) << 40) | ((static_cast<UINT64>(minor) & 0xFFFFFF) << 16) | (static_cast<UINT64>(patch) & 0xFFFF)
|
||||
#define IA_STRINGIFY_VERSION(version) BuildString("v", (version >> 40) & 0xFFFFFF, ".", (version >> 16) & 0xFFFFFF, ".", version & 0xFFFF)
|
||||
#define IA_MAKE_VERSION(major, minor, patch) \
|
||||
((static_cast<UINT64>(major) & 0xFFFFFF) << 40) | ((static_cast<UINT64>(minor) & 0xFFFFFF) << 16) | \
|
||||
(static_cast<UINT64>(patch) & 0xFFFF)
|
||||
#define IA_STRINGIFY_VERSION(version) \
|
||||
BuildString("v", (version >> 40) & 0xFFFFFF, ".", (version >> 16) & 0xFFFFFF, ".", version & 0xFFFF)
|
||||
#define IA_PARSE_VERSION_STRING(versionString) \
|
||||
[](IN std::string str) { \
|
||||
INT32 minor, major, patch; \
|
||||
char dot; \
|
||||
std::stringstream ss(str); \
|
||||
ss >> major >> dot >> minor >> dot >> patch; \
|
||||
return IA_MAKE_VERSION(major, minor, patch); \
|
||||
}(versionString)
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define IA_DLL_EXPORT __declspec(dllexport)
|
||||
#define IA_DLL_IMPORT __declspec(dllimport)
|
||||
#define IA_DLL_EXPORT __declspec(dllexport)
|
||||
#define IA_DLL_IMPORT __declspec(dllimport)
|
||||
#elif defined(__GNUC__)
|
||||
#define IA_DLL_EXPORT __attribute__((visibility("default")))
|
||||
#define IA_DLL_IMPORT
|
||||
#define IA_DLL_EXPORT __attribute__((visibility("default")))
|
||||
#define IA_DLL_IMPORT
|
||||
#else
|
||||
#define IA_DLL_EXPORT
|
||||
#define IA_DLL_IMPORT
|
||||
#define IA_DLL_EXPORT
|
||||
#define IA_DLL_IMPORT
|
||||
#endif
|
||||
|
||||
#define __CC_BLACK "\033[30m"
|
||||
|
||||
114
Src/IACore/inc/hpp/IACore/DynamicLib.hpp
Normal file
114
Src/IACore/inc/hpp/IACore/DynamicLib.hpp
Normal file
@ -0,0 +1,114 @@
|
||||
// IACore-OSS; The Core Library for All IA Open Source Projects
|
||||
// Copyright (C) 2024 IAS (ias@iasoft.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <IACore/Exception.hpp>
|
||||
#include <IACore/String.hpp>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#elif defined(__linux__) || defined(__APPLE__)
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
namespace ia
|
||||
{
|
||||
class DynamicLib
|
||||
{
|
||||
public:
|
||||
STATIC INLINE DynamicLib Load(IN CONST String &searchPath, IN CONST String &name);
|
||||
|
||||
INLINE ~DynamicLib();
|
||||
|
||||
INLINE VOID Destroy();
|
||||
|
||||
public:
|
||||
INLINE PVOID GetSymbol(IN CONST String &name);
|
||||
|
||||
template<typename FunctionType> FunctionType GetFunction(IN CONST String &name)
|
||||
{
|
||||
return reinterpret_cast<FunctionType>(GetSymbol(name));
|
||||
}
|
||||
|
||||
private:
|
||||
INLINE DynamicLib(IN PVOID moduleHandle);
|
||||
|
||||
private:
|
||||
CONST PVOID m_moduleHandle;
|
||||
};
|
||||
} // namespace ia
|
||||
|
||||
namespace ia
|
||||
{
|
||||
DynamicLib::DynamicLib(IN PVOID moduleHandle) : m_moduleHandle(moduleHandle)
|
||||
{
|
||||
}
|
||||
|
||||
DynamicLib::~DynamicLib()
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
DynamicLib DynamicLib::Load(IN CONST String &searchPath, IN CONST String &name)
|
||||
{
|
||||
const auto handle = LoadLibraryA(BuildString(searchPath, "/", name, ".dll").c_str());
|
||||
if (handle == NULL)
|
||||
THROW_UNKNOWN("DynamicLib: Failed to load the library \"", name, "\" with error: ", GetLastError());
|
||||
return DynamicLib((PVOID) handle);
|
||||
}
|
||||
|
||||
PVOID DynamicLib::GetSymbol(IN CONST String &name)
|
||||
{
|
||||
const auto symbol = GetProcAddress(static_cast<HMODULE>(m_moduleHandle), name.c_str());
|
||||
if (symbol == NULL)
|
||||
THROW_UNKNOWN("DynamicLib: Failed to find the symbol \"", name, "\" with error: ", GetLastError());
|
||||
return (PVOID) symbol;
|
||||
}
|
||||
|
||||
VOID DynamicLib::Destroy()
|
||||
{
|
||||
if (m_moduleHandle)
|
||||
FreeLibrary(static_cast<HMODULE>(m_moduleHandle));
|
||||
}
|
||||
#else
|
||||
DynamicLib DynamicLib::Load(IN CONST String &searchPath, IN CONST String &name)
|
||||
{
|
||||
dlerror();
|
||||
const auto handle = dlopen(BuildString(searchPath, "/", name, ".so").c_str(), RTLD_LAZY);
|
||||
if (handle == NULL)
|
||||
THROW_UNKNOWN("DynamicLib: Failed to load the library \"", name, "\" with error: ", dlerror());
|
||||
return DynamicLib((PVOID) handle);
|
||||
}
|
||||
|
||||
PVOID DynamicLib::GetSymbol(IN CONST String &name)
|
||||
{
|
||||
dlerror();
|
||||
const auto symbol = dlsym(m_moduleHandle, name.c_str());
|
||||
const char *dlsym_error = dlerror();
|
||||
if (dlsym_error)
|
||||
THROW_UNKNOWN("DynamicLib: Failed to find the symbol \"", name, "\" with error: ", dlerror());
|
||||
return (PVOID) symbol;
|
||||
}
|
||||
|
||||
VOID DynamicLib::Destroy()
|
||||
{
|
||||
if (m_moduleHandle)
|
||||
dlclose(m_moduleHandle);
|
||||
}
|
||||
#endif
|
||||
} // namespace ia
|
||||
23
Src/IACore/inc/hpp/IACore/Environment.hpp
Normal file
23
Src/IACore/inc/hpp/IACore/Environment.hpp
Normal file
@ -0,0 +1,23 @@
|
||||
// IACore-OSS; The Core Library for All IA Open Source Projects
|
||||
// Copyright (C) 2024 IAS (ias@iasoft.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <IACore/platform/environment.inl>
|
||||
|
||||
namespace ia
|
||||
{
|
||||
} // namespace ia
|
||||
23
Src/IACore/inc/hpp/IACore/Process.hpp
Normal file
23
Src/IACore/inc/hpp/IACore/Process.hpp
Normal file
@ -0,0 +1,23 @@
|
||||
// IACore-OSS; The Core Library for All IA Open Source Projects
|
||||
// Copyright (C) 2024 IAS (ias@iasoft.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <IACore/platform/process.inl>
|
||||
|
||||
namespace ia
|
||||
{
|
||||
} // namespace ia
|
||||
28
Src/IACore/inc/hpp/IACore/Thread.hpp
Normal file
28
Src/IACore/inc/hpp/IACore/Thread.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
// IACore-OSS; The Core Library for All IA Open Source Projects
|
||||
// Copyright (C) 2024 IAS (ias@iasoft.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <IACore/Types.hpp>
|
||||
|
||||
#include <thread>
|
||||
#include <future>
|
||||
|
||||
namespace ia
|
||||
{
|
||||
using Mutex = std::mutex;
|
||||
using ScopeMutex = std::lock_guard<Mutex>;
|
||||
}
|
||||
@ -22,6 +22,7 @@
|
||||
|
||||
namespace ia
|
||||
{
|
||||
template<typename _value_type> using InitializerList = std::initializer_list<_value_type>;
|
||||
template<typename _value_type> using initializer_list = std::initializer_list<_value_type>;
|
||||
|
||||
#undef VOID
|
||||
@ -98,6 +99,9 @@ namespace ia
|
||||
typedef CONST FLOAT32 PCFLOAT32;
|
||||
typedef CONST FLOAT64 PCFLOAT64;
|
||||
|
||||
template<typename function_type>
|
||||
using Function = std::function<function_type>;
|
||||
|
||||
/* Uses the UEFI standard GUID structure definition */
|
||||
typedef struct _IA_GUID
|
||||
{
|
||||
|
||||
@ -1,34 +1,38 @@
|
||||
#include <IACore/Logger.hpp>
|
||||
#include <IACore/File.hpp>
|
||||
#include <IACore/Logger.hpp>
|
||||
|
||||
#include <IACore/Vector.hpp>
|
||||
#include <IACore/Map.hpp>
|
||||
#include <IACore/Vector.hpp>
|
||||
|
||||
#include <IACore/Process.hpp>
|
||||
#include <IACore/Environment.hpp>
|
||||
|
||||
#include <IACore/DynamicLib.hpp>
|
||||
|
||||
using namespace ia;
|
||||
|
||||
template<typename _value_type>
|
||||
VOID print(IN CONST Span<_value_type>& s)
|
||||
template<typename _value_type> VOID print(IN CONST Span<_value_type> &s)
|
||||
{
|
||||
for(const auto& v: s)
|
||||
for (const auto &v : s)
|
||||
Logger::Info("IACore", v);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Vector<int> v1{10, 20, 32};
|
||||
|
||||
/*ector<int> v1{10, 20, 32};
|
||||
print(v1);
|
||||
|
||||
List<int> l1;
|
||||
|
||||
Map<String, int> m1;
|
||||
m1["sdd"] = 2;
|
||||
m1["bx"] = 5;
|
||||
|
||||
for(const auto& v: m1)
|
||||
{
|
||||
for (const auto &v : m1)
|
||||
printf("%s, %i\n", v->Key.c_str(), v->Value);
|
||||
}
|
||||
SubProcess p("clang++");
|
||||
p.Launch("a.cpp", [](IN CONST String &line) { printf("[\n%s\n]\n", line.c_str()); });*/
|
||||
|
||||
//printf("[%s]\n", Environment::GetVar("IAEDK_ROOT").c_str());
|
||||
//Environment::SetVar("IAEDK_ROOT", "C:\\IAEDK");
|
||||
//printf("[%s]\n", Environment::GetVar("IAEDK_ROOT").c_str());
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user