From 07dc60434655570520fb0261d5f1779098c95eb1 Mon Sep 17 00:00:00 2001 From: dev0 Date: Sat, 17 Jan 2026 04:05:27 +0530 Subject: [PATCH] [FEAT]: CLIParser (Alpha) --- Src/IACore/CMakeLists.txt | 1 + Src/IACore/imp/cpp/CLI.cpp | 30 +++++++++++++++ Src/IACore/inc/IACore/CLI.hpp | 70 +++++++++++++++++++++++++++++++++++ Src/IACore/inc/IACore/PCH.hpp | 3 ++ 4 files changed, 104 insertions(+) create mode 100644 Src/IACore/imp/cpp/CLI.cpp create mode 100644 Src/IACore/inc/IACore/CLI.hpp diff --git a/Src/IACore/CMakeLists.txt b/Src/IACore/CMakeLists.txt index 5a1836b..d79e45a 100644 --- a/Src/IACore/CMakeLists.txt +++ b/Src/IACore/CMakeLists.txt @@ -1,4 +1,5 @@ set(SRC_FILES + "imp/cpp/CLI.cpp" "imp/cpp/IPC.cpp" "imp/cpp/XML.cpp" "imp/cpp/SIMD.cpp" diff --git a/Src/IACore/imp/cpp/CLI.cpp b/Src/IACore/imp/cpp/CLI.cpp new file mode 100644 index 0000000..a5db98c --- /dev/null +++ b/Src/IACore/imp/cpp/CLI.cpp @@ -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 + +namespace IACore +{ + CLIParser::CLIParser(IN Span 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 \ No newline at end of file diff --git a/Src/IACore/inc/IACore/CLI.hpp b/Src/IACore/inc/IACore/CLI.hpp new file mode 100644 index 0000000..f15ac2b --- /dev/null +++ b/Src/IACore/inc/IACore/CLI.hpp @@ -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 + +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 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 m_argList; + Span::const_iterator m_currentArg; + }; +} // namespace IACore \ No newline at end of file diff --git a/Src/IACore/inc/IACore/PCH.hpp b/Src/IACore/inc/IACore/PCH.hpp index e129411..ffc2bb3 100644 --- a/Src/IACore/inc/IACore/PCH.hpp +++ b/Src/IACore/inc/IACore/PCH.hpp @@ -379,6 +379,9 @@ #define IA_MAX_STRING_LENGTH (IA_MAX_POSSIBLE_SIZE >> 8) #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) \ ((((uint64_t) (major) & 0xFFFFFF) << 40) | (((uint64_t) (minor) & 0xFFFFFF) << 16) | ((uint64_t) (patch) & 0xFFFF))