[FEAT]: CLIParser (Alpha)

This commit is contained in:
2026-01-17 04:05:27 +05:30
parent 38e4e216c8
commit 07dc604346
4 changed files with 104 additions and 0 deletions

View File

@ -1,4 +1,5 @@
set(SRC_FILES set(SRC_FILES
"imp/cpp/CLI.cpp"
"imp/cpp/IPC.cpp" "imp/cpp/IPC.cpp"
"imp/cpp/XML.cpp" "imp/cpp/XML.cpp"
"imp/cpp/SIMD.cpp" "imp/cpp/SIMD.cpp"

View File

@ -0,0 +1,30 @@
// IACore-OSS; The Core Library for All IA Open Source Projects
// Copyright (C) 2026 IAS (ias@iasoft.dev)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <IACore/CLI.hpp>
namespace IACore
{
CLIParser::CLIParser(IN Span<CONST String> args) : m_argList(args)
{
IA_RELEASE_ASSERT(args.size());
m_currentArg = m_argList.begin();
// Skip executable path
if (m_currentArg != m_argList.end())
m_currentArg++;
}
} // namespace IACore

View File

@ -0,0 +1,70 @@
// IACore-OSS; The Core Library for All IA Open Source Projects
// Copyright (C) 2026 IAS (ias@iasoft.dev)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <IACore/PCH.hpp>
namespace IACore
{
class CLIParser
{
/*
* PLEASE READ
*
* CLIParser is still very much in it's baby stages.
* Subject to heavy and frequent changes, use with
* caution!
*/
public:
CLIParser(IN Span<CONST String> args);
~CLIParser() = default;
public:
BOOL Remaining() CONST
{
return m_currentArg < m_argList.end();
}
StringView Peek() CONST
{
if (!Remaining())
return "";
return *m_currentArg;
}
StringView Next()
{
if (!Remaining())
return "";
return *m_currentArg++;
}
BOOL Consume(IN CONST StringView &expected)
{
if (Peek() == expected)
{
Next();
return true;
}
return false;
}
private:
CONST Span<CONST String> m_argList;
Span<CONST String>::const_iterator m_currentArg;
};
} // namespace IACore

View File

@ -379,6 +379,9 @@
#define IA_MAX_STRING_LENGTH (IA_MAX_POSSIBLE_SIZE >> 8) #define IA_MAX_STRING_LENGTH (IA_MAX_POSSIBLE_SIZE >> 8)
#define IA_VERSION_TYPE uint64_t #define IA_VERSION_TYPE uint64_t
#define IA_VERSION_MAJOR(v) ((v >> 40) & 0xFFFFFF)
#define IA_VERSION_MINOR(v) ((v >> 16) & 0xFFFFFF)
#define IA_VERSION_PATCH(v) (v & 0xFFFF)
#define IA_MAKE_VERSION(major, minor, patch) \ #define IA_MAKE_VERSION(major, minor, patch) \
((((uint64_t) (major) & 0xFFFFFF) << 40) | (((uint64_t) (minor) & 0xFFFFFF) << 16) | ((uint64_t) (patch) & 0xFFFF)) ((((uint64_t) (major) & 0xFFFFFF) << 40) | (((uint64_t) (minor) & 0xFFFFFF) << 16) | ((uint64_t) (patch) & 0xFFFF))