This commit is contained in:
Isuru Samarathunga
2025-10-22 09:33:54 +05:30
parent 07638ea7b3
commit 9bf876f823
6 changed files with 42 additions and 8 deletions

View File

@ -62,7 +62,7 @@ namespace ia
VOID MemoryStreamReader::Read(IN INT64 size, IN PUINT8 buffer) VOID MemoryStreamReader::Read(IN INT64 size, IN PUINT8 buffer)
{ {
IA_RELEASE_ASSERT((m_cursor + size) <= m_buffer.size()); IA_RELEASE_ASSERT((m_cursor + size) <= m_buffer.size());
memcpy_s(buffer, size, &m_buffer[m_cursor], size); memcpy(buffer, &m_buffer[m_cursor], size);
m_cursor += size; m_cursor += size;
} }
@ -113,7 +113,7 @@ namespace ia
FileStreamReader::FileStreamReader(IN PCCHAR filePath) FileStreamReader::FileStreamReader(IN PCCHAR filePath)
{ {
fopen_s(&m_filePtr, filePath, "rb"); m_filePtr = fopen(filePath, "rb");
if (!m_filePtr) if (!m_filePtr)
THROW_FILE_OPEN_READ(filePath); THROW_FILE_OPEN_READ(filePath);
} }

View File

@ -16,7 +16,7 @@
#pragma once #pragma once
#include <IACore/Container.hpp> #include <IACore/Vector.hpp>
namespace ia namespace ia
{ {
@ -96,6 +96,10 @@ namespace ia
INLINE StringT slice(IN size_type start, IN size_type end, IN size_type stride = 1) CONST; INLINE StringT slice(IN size_type start, IN size_type end, IN size_type stride = 1) CONST;
INLINE StringT slice(IN const_iterator first, IN const_iterator last, IN size_type stride = 1) CONST; INLINE StringT slice(IN const_iterator first, IN const_iterator last, IN size_type stride = 1) CONST;
INLINE Vector<StringT> split(IN CHAR delimiter);
template<typename _value_type>
INLINE STATIC StringT join(IN CONST Vector<_value_type>& values, IN CHAR delimiter);
public: public:
VOID operator+=(IN char_type v) VOID operator+=(IN char_type v)
{ {

View File

@ -228,6 +228,32 @@ namespace ia
return { Base::m_data + insert_at + n }; return { Base::m_data + insert_at + n };
} }
define_member_function(Vector<__ia__identifier>, split, IN CHAR delimiter)
{
Vector<__ia__identifier> result;
SIZE_T t = 0;
for(SIZE_T i = 0; i < length(); i++)
{
if(Base::m_data[i] == delimiter)
{
result.pushBack(slice(t, i + 1));
t = i + 1;
}
}
if(t < length())
result.pushBack(slice(t, Base::m_count));
return result;
}
define_member_function(template<typename _value_type> __ia__identifier, join, IN CONST Vector<_value_type>& values, IN CHAR delimiter)
{
__ia__identifier result;
// [IATODO]
return result;
}
#undef put_element #undef put_element
#undef move_element #undef move_element
#undef move_elements #undef move_elements

View File

@ -203,7 +203,7 @@ namespace ia
for (const auto &v : t->Value.Switches) for (const auto &v : t->Value.Switches)
{ {
printf(__CC_WHITE, "\t/%s %s\n", v.ID.c_str(), v.Help.c_str()); printf(__CC_WHITE "//%s %s\n", v.ID.c_str(), v.Help.c_str());
} }
printf(__CC_DEFAULT "\n"); printf(__CC_DEFAULT "\n");

View File

@ -20,6 +20,10 @@
#include <IACore/String.hpp> #include <IACore/String.hpp>
#include <IACore/Vector.hpp> #include <IACore/Vector.hpp>
#ifdef __ANDROID__
#include <android/asset_manager.h>
#endif
namespace ia namespace ia
{ {
class File class File

View File

@ -32,7 +32,7 @@ namespace ia
StringStream ss; StringStream ss;
UNUSED((ss << ... << args)); UNUSED((ss << ... << args));
#ifdef __ANDROID__ #ifdef __ANDROID__
__android_log_print(ANDROID_LOG_DEBUG, "IAApp", ss.str().c_str()); __android_log_print(ANDROID_LOG_DEBUG, "IAApp", "%s", ss.str().c_str());
#else #else
printf("\033[0;37m[INFO]: [%s] %s\033[39m\n", tag, ss.str().c_str()); printf("\033[0;37m[INFO]: [%s] %s\033[39m\n", tag, ss.str().c_str());
#endif #endif
@ -43,7 +43,7 @@ namespace ia
StringStream ss; StringStream ss;
UNUSED((ss << ... << args)); UNUSED((ss << ... << args));
#ifdef __ANDROID__ #ifdef __ANDROID__
__android_log_print(ANDROID_LOG_INFO, "IAApp", ss.str().c_str()); __android_log_print(ANDROID_LOG_INFO, "IAApp", "%s", ss.str().c_str());
#else #else
printf("\033[32m[SUCCESS]: [%s] %s\033[39m\n", tag, ss.str().c_str()); printf("\033[32m[SUCCESS]: [%s] %s\033[39m\n", tag, ss.str().c_str());
#endif #endif
@ -54,7 +54,7 @@ namespace ia
StringStream ss; StringStream ss;
UNUSED((ss << ... << args)); UNUSED((ss << ... << args));
#ifdef __ANDROID__ #ifdef __ANDROID__
__android_log_print(ANDROID_LOG_DEBUG, "IAApp", ss.str().c_str()); __android_log_print(ANDROID_LOG_DEBUG, "IAApp", "%s", ss.str().c_str());
#else #else
printf("\033[33m[WARN]: [%s] %s\033[39m\n", tag, ss.str().c_str()); printf("\033[33m[WARN]: [%s] %s\033[39m\n", tag, ss.str().c_str());
#endif #endif
@ -65,7 +65,7 @@ namespace ia
StringStream ss; StringStream ss;
UNUSED((ss << ... << args)); UNUSED((ss << ... << args));
#ifdef __ANDROID__ #ifdef __ANDROID__
__android_log_print(ANDROID_LOG_ERROR, "IAApp", ss.str().c_str()); __android_log_print(ANDROID_LOG_ERROR, "IAApp", "%s", ss.str().c_str());
#else #else
printf("\033[31m[ERROR]: [%s] %s\033[39m\n", tag, ss.str().c_str()); printf("\033[31m[ERROR]: [%s] %s\033[39m\n", tag, ss.str().c_str());
#endif #endif