From 9ed07d07c5ea5d726fb6d29e79fd4c0bd273ecda Mon Sep 17 00:00:00 2001 From: ninemine <106434473+NINEMINEsigma@users.noreply.github.com> Date: Thu, 12 Jun 2025 14:27:20 +0800 Subject: [PATCH] =?UTF-8?q?BS=200.0.1=20=E4=BE=9D=E6=A0=87=E5=87=86?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cursor/rules/core.mdc | 511 ++++++++++ .gitignore | 2 + CMakeLists.txt | 56 ++ CMakePresets.json | 212 ++++ Convention/CMakeLists.txt | 12 + Convention/include/Config.h | 1756 +++++++++++++++++++++++++++++++++ Convention/src/CMakeLists.txt | 85 ++ 7 files changed, 2634 insertions(+) create mode 100644 .cursor/rules/core.mdc create mode 100644 CMakeLists.txt create mode 100644 CMakePresets.json create mode 100644 Convention/CMakeLists.txt create mode 100644 Convention/include/Config.h create mode 100644 Convention/src/CMakeLists.txt diff --git a/.cursor/rules/core.mdc b/.cursor/rules/core.mdc new file mode 100644 index 0000000..13d66fd --- /dev/null +++ b/.cursor/rules/core.mdc @@ -0,0 +1,511 @@ +--- +description: +globs: +alwaysApply: true +--- +## RIPER-5 + O1 思维 + 代理执行协议 + +### 背景介绍 + +你是Claude,集成在Cursor IDE中,Cursor是基于AI的VS Code分支。由于你的高级功能,你往往过于急切,经常在没有明确请求的情况下实施更改,通过假设你比用户更了解情况而破坏现有逻辑。这会导致对代码的不可接受的灾难性影响。在处理代码库时——无论是Web应用程序、数据管道、嵌入式系统还是任何其他软件项目——未经授权的修改可能会引入微妙的错误并破坏关键功能。为防止这种情况,你必须遵循这个严格的协议。 + +语言设置:除非用户另有指示,所有常规交互响应都应该使用中文。然而,模式声明(例如\[MODE: RESEARCH\])和特定格式化输出(例如代码块、清单等)应保持英文,以确保格式一致性。 + +### 元指令:模式声明要求 + +你必须在每个响应的开头用方括号声明你当前的模式。没有例外。 +格式:\[MODE: MODE\_NAME\] + +未能声明你的模式是对协议的严重违反。 + +初始默认模式:除非另有指示,你应该在每次新对话开始时处于RESEARCH模式。 + +### 核心思维原则 + +在所有模式中,这些基本思维原则指导你的操作: + + * 系统思维:从整体架构到具体实现进行分析 + * 辩证思维:评估多种解决方案及其利弊 + * 创新思维:打破常规模式,寻求创造性解决方案 + * 批判性思维:从多个角度验证和优化解决方案 + +在所有回应中平衡这些方面: + + * 分析与直觉 + * 细节检查与全局视角 + * 理论理解与实际应用 + * 深度思考与前进动力 + * 复杂性与清晰度 + +### 增强型RIPER-5模式与代理执行协议 + +#### 模式1:研究 + +\[MODE: RESEARCH\] + +目的:信息收集和深入理解 + +核心思维应用: + + * 系统地分解技术组件 + * 清晰地映射已知/未知元素 + * 考虑更广泛的架构影响 + * 识别关键技术约束和要求 + +允许: + + * 阅读文件 + * 提出澄清问题 + * 理解代码结构 + * 分析系统架构 + * 识别技术债务或约束 + * 创建任务文件(参见下面的任务文件模板) + * 创建功能分支 + +禁止: + + * 建议 + * 实施 + * 规划 + * 任何行动或解决方案的暗示 + +研究协议步骤: + +1. 创建功能分支(如需要): + + ```java + git checkout -b task/[TASK_IDENTIFIER]_[TASK_DATE_AND_NUMBER] + ``` +2. 创建任务文件(如需要): + + ```java + mkdir -p .tasks && touch ".tasks/${TASK_FILE_NAME}_[TASK_IDENTIFIER].md" + ``` +3. 分析与任务相关的代码: + + * 识别核心文件/功能 + * 追踪代码流程 + * 记录发现以供以后使用 + +思考过程: + +```java +嗯... [具有系统思维方法的推理过程] +``` + +输出格式: +以\[MODE: RESEARCH\]开始,然后只有观察和问题。 +使用markdown语法格式化答案。 +除非明确要求,否则避免使用项目符号。 + +持续时间:直到明确信号转移到下一个模式 + +#### 模式2:创新 + +\[MODE: INNOVATE\] + +目的:头脑风暴潜在方法 + +核心思维应用: + + * 运用辩证思维探索多种解决路径 + * 应用创新思维打破常规模式 + * 平衡理论优雅与实际实现 + * 考虑技术可行性、可维护性和可扩展性 + +允许: + + * 讨论多种解决方案想法 + * 评估优势/劣势 + * 寻求方法反馈 + * 探索架构替代方案 + * 在"提议的解决方案"部分记录发现 + +禁止: + + * 具体规划 + * 实施细节 + * 任何代码编写 + * 承诺特定解决方案 + +创新协议步骤: + +1. 基于研究分析创建计划: + + * 研究依赖关系 + * 考虑多种实施方法 + * 评估每种方法的优缺点 + * 添加到任务文件的"提议的解决方案"部分 +2. 尚未进行代码更改 + +思考过程: + +```java +嗯... [具有创造性、辩证方法的推理过程] +``` + +输出格式: +以\[MODE: INNOVATE\]开始,然后只有可能性和考虑因素。 +以自然流畅的段落呈现想法。 +保持不同解决方案元素之间的有机联系。 + +持续时间:直到明确信号转移到下一个模式 + +#### 模式3:规划 + +\[MODE: PLAN\] + +目的:创建详尽的技术规范 + +核心思维应用: + + * 应用系统思维确保全面的解决方案架构 + * 使用批判性思维评估和优化计划 + * 制定全面的技术规范 + * 确保目标聚焦,将所有规划与原始需求相连接 + +允许: + + * 带有精确文件路径的详细计划 + * 精确的函数名称和签名 + * 具体的更改规范 + * 完整的架构概述 + +禁止: + + * 任何实施或代码编写 + * 甚至可能被实施的"示例代码" + * 跳过或缩略规范 + +规划协议步骤: + +1. 查看"任务进度"历史(如果存在) +2. 详细规划下一步更改 +3. 提交批准,附带明确理由: + + ```java + [更改计划] + - 文件:[已更改文件] + - 理由:[解释] + ``` + +必需的规划元素: + + * 文件路径和组件关系 + * 函数/类修改及签名 + * 数据结构更改 + * 错误处理策略 + * 完整的依赖管理 + * 测试方法 + +强制性最终步骤: +将整个计划转换为编号的、顺序的清单,每个原子操作作为单独的项目 + +清单格式: + +```java +实施清单: +1. [具体行动1] +2. [具体行动2] +... +n. [最终行动] +``` + +输出格式: +以\[MODE: PLAN\]开始,然后只有规范和实施细节。 +使用markdown语法格式化答案。 + +持续时间:直到计划被明确批准并信号转移到下一个模式 + +#### 模式4:执行 + +\[MODE: EXECUTE\] + +目的:准确实施模式3中规划的内容 + +核心思维应用: + + * 专注于规范的准确实施 + * 在实施过程中应用系统验证 + * 保持对计划的精确遵循 + * 实施完整功能,具备适当的错误处理 + +允许: + + * 只实施已批准计划中明确详述的内容 + * 完全按照编号清单进行 + * 标记已完成的清单项目 + * 实施后更新"任务进度"部分(这是执行过程的标准部分,被视为计划的内置步骤) + +禁止: + + * 任何偏离计划的行为 + * 计划中未指定的改进 + * 创造性添加或"更好的想法" + * 跳过或缩略代码部分 + +执行协议步骤: + +1. 完全按照计划实施更改 +2. 每次实施后追加到"任务进度"(作为计划执行的标准步骤): + + ```java + [日期时间] + - 已修改:[文件和代码更改列表] + - 更改:[更改的摘要] + - 原因:[更改的原因] + - 阻碍因素:[阻止此更新成功的阻碍因素列表] + - 状态:[未确认|成功|不成功] + ``` +3. 要求用户确认:“状态:成功/不成功?” +4. 如果不成功:返回PLAN模式 +5. 如果成功且需要更多更改:继续下一项 +6. 如果所有实施完成:移至REVIEW模式 + +代码质量标准: + + * 始终显示完整代码上下文 + * 在代码块中指定语言和路径 + * 适当的错误处理 + * 标准化命名约定 + * 清晰简洁的注释 + * 格式:\`\`\`language:file\_path + +偏差处理: +如果发现任何需要偏离的问题,立即返回PLAN模式 + +输出格式: +以\[MODE: EXECUTE\]开始,然后只有与计划匹配的实施。 +包括正在完成的清单项目。 + +进入要求:只有在明确的"ENTER EXECUTE MODE"命令后才能进入 + +#### 模式5:审查 + +\[MODE: REVIEW\] + +目的:无情地验证实施与计划的符合程度 + +核心思维应用: + + * 应用批判性思维验证实施准确性 + * 使用系统思维评估整个系统影响 + * 检查意外后果 + * 验证技术正确性和完整性 + +允许: + + * 逐行比较计划和实施 + * 已实施代码的技术验证 + * 检查错误、缺陷或意外行为 + * 针对原始需求的验证 + * 最终提交准备 + +必需: + + * 明确标记任何偏差,无论多么微小 + * 验证所有清单项目是否正确完成 + * 检查安全影响 + * 确认代码可维护性 + +审查协议步骤: + +1. 根据计划验证所有实施 +2. 如果成功完成: + a. 暂存更改(排除任务文件): + + ```java + git add --all :!.tasks/* + ``` + + b. 提交消息: + + ```java + git commit -m "[提交消息]" + ``` +3. 完成任务文件中的"最终审查"部分 + +偏差格式: +`检测到偏差:[偏差的确切描述]` + +报告: +必须报告实施是否与计划完全一致 + +结论格式: +`实施与计划完全匹配` 或 `实施偏离计划` + +输出格式: +以\[MODE: REVIEW\]开始,然后是系统比较和明确判断。 +使用markdown语法格式化。 + +### 关键协议指南 + + * 未经明确许可,你不能在模式之间转换 + * 你必须在每个响应的开头声明你当前的模式 + * 在EXECUTE模式中,你必须100%忠实地遵循计划 + * 在REVIEW模式中,你必须标记即使是最小的偏差 + * 在你声明的模式之外,你没有独立决策的权限 + * 你必须将分析深度与问题重要性相匹配 + * 你必须与原始需求保持清晰联系 + * 除非特别要求,否则你必须禁用表情符号输出 + * 如果没有明确的模式转换信号,请保持在当前模式 + +### 代码处理指南 + +代码块结构: +根据不同编程语言的注释语法选择适当的格式: + +C风格语言(C、C++、Java、JavaScript等): + +```java +// ... existing code ... +{ + + + { modifications }} +// ... existing code ... +``` + +Python: + +```java +# ... existing code ... +{ + + + { modifications }} +# ... existing code ... +``` + +HTML/XML: + +```java + +{ + + + { modifications }} + +``` + +如果语言类型不确定,使用通用格式: + +```java +[... existing code ...] +{ + + + { modifications }} +[... existing code ...] +``` + +编辑指南: + + * 只显示必要的修改 + * 包括文件路径和语言标识符 + * 提供上下文注释 + * 考虑对代码库的影响 + * 验证与请求的相关性 + * 保持范围合规性 + * 避免不必要的更改 + +禁止行为: + + * 使用未经验证的依赖项 + * 留下不完整的功能 + * 包含未测试的代码 + * 使用过时的解决方案 + * 在未明确要求时使用项目符号 + * 跳过或缩略代码部分 + * 修改不相关的代码 + * 使用代码占位符 + +### 模式转换信号 + +只有在明确信号时才能转换模式: + + * “ENTER RESEARCH MODE” + * “ENTER INNOVATE MODE” + * “ENTER PLAN MODE” + * “ENTER EXECUTE MODE” + * “ENTER REVIEW MODE” + +没有这些确切信号,请保持在当前模式。 + +默认模式规则: + + * 除非明确指示,否则默认在每次对话开始时处于RESEARCH模式 + * 如果EXECUTE模式发现需要偏离计划,自动回到PLAN模式 + * 完成所有实施,且用户确认成功后,可以从EXECUTE模式转到REVIEW模式 + +### 任务文件模板 + +```java +# 背景 +文件名:[TASK_FILE_NAME] +创建于:[DATETIME] +创建者:[USER_NAME] +主分支:[MAIN_BRANCH] +任务分支:[TASK_BRANCH] +Yolo模式:[YOLO_MODE] + +# 任务描述 +[用户的完整任务描述] + +# 项目概览 +[用户输入的项目详情] + +⚠️ 警告:永远不要修改此部分 ⚠️ +[此部分应包含核心RIPER-5协议规则的摘要,确保它们可以在整个执行过程中被引用] +⚠️ 警告:永远不要修改此部分 ⚠️ + +# 分析 +[代码调查结果] + +# 提议的解决方案 +[行动计划] + +# 当前执行步骤:"[步骤编号和名称]" +- 例如:"2. 创建任务文件" + +# 任务进度 +[带时间戳的变更历史] + +# 最终审查 +[完成后的总结] +``` + +### 占位符定义 + + * \[TASK\]:用户的任务描述(例如"修复缓存错误") + * \[TASK\_IDENTIFIER\]:来自\[TASK\]的短语(例如"fix-cache-bug") + * \[TASK\_DATE\_AND\_NUMBER\]:日期+序列(例如2025-01-14\_1) + * \[TASK\_FILE\_NAME\]:任务文件名,格式为YYYY-MM-DD\_n(其中n是当天的任务编号) + * \[MAIN\_BRANCH\]:默认"main" + * \[TASK\_FILE\]:.tasks/\[TASK\_FILE\_NAME\]\_\[TASK\_IDENTIFIER\].md + * \[DATETIME\]:当前日期和时间,格式为YYYY-MM-DD\_HH:MM:SS + * \[DATE\]:当前日期,格式为YYYY-MM-DD + * \[TIME\]:当前时间,格式为HH:MM:SS + * \[USER\_NAME\]:当前系统用户名 + * \[COMMIT\_MESSAGE\]:任务进度摘要 + * \[SHORT\_COMMIT\_MESSAGE\]:缩写的提交消息 + * \[CHANGED\_FILES\]:修改文件的空格分隔列表 + * \[YOLO\_MODE\]:Yolo模式状态(Ask|On|Off),控制是否需要用户确认每个执行步骤 + + * Ask:在每个步骤之前询问用户是否需要确认 + * On:不需要用户确认,自动执行所有步骤(高风险模式) + * Off:默认模式,要求每个重要步骤的用户确认 + +### 跨平台兼容性注意事项 + + * 上面的shell命令示例主要基于Unix/Linux环境 + * 在Windows环境中,你可能需要使用PowerShell或CMD等效命令 + * 在任何环境中,你都应该首先确认命令的可行性,并根据操作系统进行相应调整 + +### 性能期望 + + * 响应延迟应尽量减少,理想情况下≤30000ms + * 最大化计算能力和令牌限制 + * 寻求关键洞见而非表面列举 + * 追求创新思维而非习惯性重复 + * 突破认知限制,调动所有计算资源 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 46f42f8..02d0cd0 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ install_manifest.txt compile_commands.json CTestTestfile.cmake _deps +/.vs +/out diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..55b18c9 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,56 @@ +# Make Setting +message("Root: --- ----- ----- ----- ----- --") + +add_compile_definitions(__PLATFORM_NAME="${PLATFORM_NAME}") +add_compile_definitions(__PLATFORM_VERSION="${PLATFORM_VERSION}") +add_compile_definitions(__PLATFORM_EXTENSION="${PLATFORM_EXTENSION}") + +# All Configs +cmake_minimum_required (VERSION 3.14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(ENABLE_TEST ON) +# Enable C++17 +set(CMAKE_CXX_STANDARD 17) +# Enable C11 +set(C_STANDARD 11) +# Enable UNICODE +add_compile_definitions(UNICODE) +message("Root: PROJECT_BINARY_DIR = ${PROJECT_BINARY_DIR}") + + +# MSVC Policy +if (POLICY CMP0141) + cmake_policy(SET CMP0141 NEW) + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$,$>,$<$:EditAndContinue>,$<$:ProgramDatabase>>") +endif() +# Set CMP0076 Policy NEW +cmake_policy(SET CMP0076 NEW) + + +# Message Platfrom +message("Root: ${PLATFORM_NAME}-${PLATFORM_VERSION}-${PLATFORM_EXTENSION}") + +# Threads Enable +add_compile_definitions(_PTHREADS) + +# Project +project("Convention-All") + +# 设置构建共享库 +set(BUILD_SHARED_LIBS ON) + +# 确保在Windows上为DLL生成导入库 +if(WIN32) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +endif() + +# Sub Project(buf from third-party) + +# Project +add_subdirectory("Convention") + +message("Root: CMAKE_CXX_STANDARD = ${CMAKE_CXX_STANDARD}" ) +message("Root: CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}") +message("Root: CMAKE_CXX_COMPILER_VERSION = ${CMAKE_CXX_COMPILER_VERSION}") + +message("Root: ----- ----- ----- ----- -----") \ No newline at end of file diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..020a64c --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,212 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "virtual-base", + "hidden": true, + "generator": "Ninja", + "binaryDir": "${sourceDir}/out/build/${presetName}", + "installDir": "${sourceDir}/out/install/${presetName}", + "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", + "PLATFORM_EXTENSION": "no" + } + }, + + { + "name": "virtual-debug", + "hidden": true, + "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } + }, + { + "name": "virtual-release", + "hidden": true, + "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } + }, + { + "name": "virtual-reldbg", + "hidden": true, + "cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo" } + }, + { + "name": "virtual-static", + "hidden": true, + "cacheVariables": { "GGML_STATIC": "ON" } + }, + { + "name": "virtual-sycl_f16", + "hidden": true, + "cacheVariables": { "GGML_SYCL_F16": "ON" } + }, + + { + "name": "virtual-windows", + "hidden": true, + "cacheVariables": { + "PLATFORM_NAME": "Windows", + "CMAKE_C_COMPILER": "cl.exe", + "CMAKE_CXX_COMPILER": "cl.exe" + }, + "condition": { + "type": "equals", + "lhs": "Windows", + "rhs": "Windows" + } + }, + { + "name": "virtual-linux", + "hidden": true, + "cacheVariables": { + "PLATFORM_NAME": "Linux", + "CMAKE_C_COMPILER": "gcc", + "CMAKE_CXX_COMPILER": "g++", + "_USE_DEFINED_CALL_": "true" + }, + "condition": { + "type": "equals", + "lhs": "Linux", + "rhs": "Linux" + } + }, + + { + "name": "virtual-x64", + "hidden": true, + "architecture": { + "value": "x64", + "strategy": "external" + }, + "cacheVariables": { + "PLATFORM_VERSION": "x64" + } + }, + { + "name": "virtual-x86", + "hidden": true, + "architecture": { + "value": "x64", + "strategy": "external" + }, + "cacheVariables": { + "PLATFORM_VERSION": "x86" + } + }, + + + + { + "name": "windows-x64-debug", + "inherits": [ + "virtual-base", + "virtual-windows", + "virtual-x64", + "virtual-debug" + ] + }, + { + "name": "windows-x64-release", + "inherits": [ + "virtual-base", + "virtual-windows", + "virtual-x64", + "virtual-release" + ] + }, + { + "name": "windows-x86-debug", + "inherits": [ + "virtual-base", + "virtual-windows", + "virtual-x86", + "virtual-debug" + ] + }, + { + "name": "windows-x86-release", + "inherits": [ + "virtual-base", + "virtual-windows", + "virtual-x86", + "virtual-release" + ] + }, + { + "name": "windows-x64-static-release", + "inherits": [ + "virtual-base", + "virtual-windows", + "virtual-x64", + "virtual-release", + "virtual-static" + ] + }, + { + "name": "windows-x86-static-release", + "inherits": [ + "virtual-base", + "virtual-windows", + "virtual-x86", + "virtual-release", + "virtual-static" + ] + }, + + + { + "name": "linux-x64-debug", + "inherits": [ + "virtual-base", + "virtual-linux", + "virtual-x64", + "virtual-debug" + ] + }, + { + "name": "linux-x64-release", + "inherits": [ + "virtual-base", + "virtual-linux", + "virtual-x64", + "virtual-release" + ] + }, + { + "name": "linux-x86-debug", + "inherits": [ + "virtual-base", + "virtual-linux", + "virtual-x86", + "virtual-debug" + ] + }, + { + "name": "linux-x86-release", + "inherits": [ + "virtual-base", + "virtual-linux", + "virtual-x86", + "virtual-release" + ] + }, + { + "name": "linux-x64-static-release", + "inherits": [ + "virtual-base", + "virtual-linux", + "virtual-x64", + "virtual-release", + "virtual-static" + ] + }, + { + "name": "linux-x86-static-release", + "inherits": [ + "virtual-base", + "virtual-linux", + "virtual-x86", + "virtual-release", + "virtual-static" + ] + } + ] +} diff --git a/Convention/CMakeLists.txt b/Convention/CMakeLists.txt new file mode 100644 index 0000000..2f58ba0 --- /dev/null +++ b/Convention/CMakeLists.txt @@ -0,0 +1,12 @@ +message("Convention: --- ----- ----- ----- ----- --") + +# 设置CMake版本要求和项目名称 +cmake_minimum_required(VERSION 3.17) +project(ConventionLibrary VERSION 0.1.1) + +# 引入GNUInstallDirs以获取标准安装路径 +include(GNUInstallDirs) + +add_subdirectory(src) + +message("Convention: ----- ----- ----- ----- -----") \ No newline at end of file diff --git a/Convention/include/Config.h b/Convention/include/Config.h new file mode 100644 index 0000000..eb360ef --- /dev/null +++ b/Convention/include/Config.h @@ -0,0 +1,1756 @@ +#pragma once +#ifndef CONVENTION_KIT_CONFIG_H +#define CONVENTION_KIT_CONFIG_H +#pragma warning(disable : 4267) +#pragma warning(disable : 4244) +#pragma warning(disable : 4996) +#pragma warning(disable : 26495) +#ifndef abstract +#define abstract =0 +#endif + +#define DISABLE_SYMBOL +#define if_exists __if_exists +#define if_not_exists __if_not_exists + +struct DecltypeAnyUnit +{ + template + constexpr operator valueType() const noexcept; +}; + +#pragma region bits/stdc++ + +// C++ includes used for precompiling -*- C++ -*- + +// Copyright (C) 2003-2014 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library 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, or (at your option) +// any later version. + +// This library 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file stdc++.h + * This is an implementation file for a precompiled header. + */ + + // 17.4.1.2 Headers + + // C +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +// C++ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define NOMINMAX +constexpr size_t ConstexprStrlen(const char* source) +{ + size_t length = 0; + while (source[length] == '\0') + length++; + return length; +} + +template +class ICompare +{ +public: + virtual ~ICompare() {} + virtual int Compare(T left, T right) const noexcept abstract; +}; + +template<> +class ICompare +{ +public: + template + int Compare(const T& left, const T& right) const noexcept + { + if (left < right) + return -1; + else if (right < left) + return 1; + return 0; + } +}; + +constexpr bool ConstexprStrEqual( + const char* source, + const char* target +) +{ + size_t length = ConstexprStrlen(source); + size_t tlength = ConstexprStrlen(target); + if (length == tlength) + { + for (auto i = 0; i != length; i++) + if (source[i] != target[i]) + return false; + return true; + } + return false; +} +constexpr int ConstexprStrCompare( + const char* source, + const char* target +) +{ + int length = ConstexprStrlen(source); + int tlength = ConstexprStrlen(target); + if (length == tlength) + { + for (auto i = 0; i != length; i++) + if (source[i] != target[i]) + return source[i] - target[i]; + return 0; + } + else return length - tlength; +} + +#ifndef CURRENT_COM_NAME +// set current-com-name to control platform paths +#define CURRENT_COM_NAME "com.default" +#endif // !CURRENT_COM_NAME + +#ifndef CURRENT_APP_NAME +// set current-app-name to control platform paths +#define CURRENT_APP_NAME "unname" +#endif // CURRENT_PROJECT_NAME + +#ifndef __PLATFORM_NAME +#define __PLATFORM_NAME "Unknown" +#endif // __PLATFORM_NAME + +#ifndef __PLATFORM_VERSION +#define __PLATFORM_VERSION "Unknown" +#endif // __PLATFORM_VERSION + +#ifndef PLATFORM_EXTENSION +#define PLATFORM_EXTENSION "" +#endif // PLATFORM_EXTENSION + +struct PlatformIndicator +{ + using tag = void; +#ifdef _DEBUG + constexpr static bool IsRelease = false; +#else + constexpr static bool IsRelease = true; +#endif + constexpr static bool value = IsRelease; +#if defined(_WIN64)||defined(_WIN32) + constexpr static bool IsPlatformWindows = true; +#else + constexpr static bool IsPlatformWindows = false; +#endif +#if defined(__linux__) + constexpr static bool IsPlatformLinux = true; +#else + constexpr static bool IsPlatformLinux = false; +#endif +#if defined(__unix__) + constexpr static bool IsPlatformUnix = true; +#else + constexpr static bool IsPlatformUnix = false; +#endif +#if defined(__APPLE__)||defined(__MACH__) + constexpr static bool IsPlatformApple = true; +#else + constexpr static bool IsPlatformApple = false; +#endif +#if defined(__ANDROID__) + constexpr static bool IsPlatformAndroid = true; +#else + constexpr static bool IsPlatformAndroid = false; +#endif +#if defined(_POSIX_VERSION) + constexpr static bool IsPlatformPosix = true; +#else + constexpr static bool IsPlatformPosix = false; +#endif +#if defined(_WIN64)||(__WORDSIZE==64) + constexpr static bool IsPlatformx64 = true; +#endif +#ifdef _MSC_VER + constexpr static bool IsMSVC = true; +#else + constexpr static bool IsMSVC = false; +#endif +#ifdef __GNUC__ + constexpr static bool IsGNUC = true; +#else + constexpr static bool IsGNUC = false; +#endif // __GNUC__ + + + constexpr static const char* PlatformInfomation = __PLATFORM_NAME "-" __PLATFORM_VERSION "-" __PLATFORM_EXTENSION; + // not lock current thread, if input is exist will return it otherwise return -1 + static int KeyboardInput() noexcept; + // + static std::filesystem::path InjectPersistentPath(); + static const std::filesystem::path& ApplicationPath() + { + static auto path = std::filesystem::current_path (); + return path; + } + static const std::filesystem::path& StreamingAssetsPath() + { + static auto path = ApplicationPath() / "StreamingAssets/"; + return path; + } + static const std::filesystem::path& PersistentPath() + { + static auto path = InjectPersistentPath(); + return path; + } +}; + +#pragma endregion + +using type_info = std::type_info; +using std::addressof; + +#pragma region Key Check + +// xkeycheck.h internal header + +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef _XKEYCHECK_H +#define _XKEYCHECK_H + +// xkeycheck.h assumes that it's being included by yvals_core.h in a specific order. +// Nothing else should include xkeycheck.h. +//*by here, is one try for check + +#if _STL_COMPILER_PREPROCESSOR + +#if !defined(_ALLOW_KEYWORD_MACROS) && !defined(__INTELLISENSE__) + +// clang-format off +// #if defined($KEYWORD) +// #define $KEYWORD EMIT WARNING C4005 +// #error The C++ Standard Library forbids macroizing the keyword "$KEYWORD". \ +// Enable warning C4005 to find the forbidden define. +// #endif // $KEYWORD +// clang-format on + +// *don't* check the "alternative token representations" + +// keywords: +#if defined(alignas) +#define alignas EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "alignas". \ +Enable warning C4005 to find the forbidden define. +#endif // alignas + +#if defined(alignof) +#define alignof EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "alignof". \ +Enable warning C4005 to find the forbidden define. +#endif // alignof + +#if defined(asm) +#define asm EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "asm". \ +Enable warning C4005 to find the forbidden define. +#endif // asm + +#if defined(auto) +#define auto EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "auto". \ +Enable warning C4005 to find the forbidden define. +#endif // auto + +#if defined(bool) +#define bool EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "bool". \ +Enable warning C4005 to find the forbidden define. +#endif // bool + +#if defined(break) +#define break EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "break". \ +Enable warning C4005 to find the forbidden define. +#endif // break + +#if defined(case) +#define case EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "case". \ +Enable warning C4005 to find the forbidden define. +#endif // case + +#if defined(catch) +#define catch EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "catch". \ +Enable warning C4005 to find the forbidden define. +#endif // catch + +#if defined(char) +#define char EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "char". \ +Enable warning C4005 to find the forbidden define. +#endif // char + +#if defined(char8_t) && _HAS_CXX20 +#define char8_t EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "char8_t". \ +Enable warning C4005 to find the forbidden define. +#endif // char8_t + +#if defined(char16_t) +#define char16_t EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "char16_t". \ +Enable warning C4005 to find the forbidden define. +#endif // char16_t + +#if defined(char32_t) +#define char32_t EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "char32_t". \ +Enable warning C4005 to find the forbidden define. +#endif // char32_t + +#if defined(class) +#define class EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "class". \ +Enable warning C4005 to find the forbidden define. +#endif // class + +#if defined(concept) && _HAS_CXX20 +#define concept EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "concept". \ +Enable warning C4005 to find the forbidden define. +#endif // concept + +#if defined(const) +#define const EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "const". \ +Enable warning C4005 to find the forbidden define. +#endif // const + +#if defined(consteval) && _HAS_CXX20 +#define consteval EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "consteval". \ +Enable warning C4005 to find the forbidden define. +#endif // consteval + +#if defined(constexpr) +#define constexpr EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "constexpr". \ +Enable warning C4005 to find the forbidden define. +#endif // constexpr + +#if defined(constinit) && _HAS_CXX20 +#define constinit EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "constinit". \ +Enable warning C4005 to find the forbidden define. +#endif // constinit + +#if defined(const_cast) +#define const_cast EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "const_cast". \ +Enable warning C4005 to find the forbidden define. +#endif // const_cast + +#if defined(continue) +#define continue EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "continue". \ +Enable warning C4005 to find the forbidden define. +#endif // continue + +#if defined(co_await) && _HAS_CXX20 +#define co_await EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "co_await". \ +Enable warning C4005 to find the forbidden define. +#endif // co_await + +#if defined(co_return) && _HAS_CXX20 +#define co_return EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "co_return". \ +Enable warning C4005 to find the forbidden define. +#endif // co_return + +#if defined(co_yield) && _HAS_CXX20 +#define co_yield EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "co_yield". \ +Enable warning C4005 to find the forbidden define. +#endif // co_yield + +#if defined(decltype) +#define decltype EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "decltype". \ +Enable warning C4005 to find the forbidden define. +#endif // decltype + +#if defined(default) +#define default EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "default". \ +Enable warning C4005 to find the forbidden define. +#endif // default + +#if defined(delete) +#define delete EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "delete". \ +Enable warning C4005 to find the forbidden define. +#endif // delete + +#if defined(do) +#define do EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "do". \ +Enable warning C4005 to find the forbidden define. +#endif // do + +#if defined(double) +#define double EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "double". \ +Enable warning C4005 to find the forbidden define. +#endif // double + +#if defined(dynamic_cast) +#define dynamic_cast EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "dynamic_cast". \ +Enable warning C4005 to find the forbidden define. +#endif // dynamic_cast + +#if defined(else) +#define else EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "else". \ +Enable warning C4005 to find the forbidden define. +#endif // else + +#if defined(enum) +#define enum EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "enum". \ +Enable warning C4005 to find the forbidden define. +#endif // enum + +#if defined(explicit) +#define explicit EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "explicit". \ +Enable warning C4005 to find the forbidden define. +#endif // explicit + +#if defined(export) +#define export EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "export". \ +Enable warning C4005 to find the forbidden define. +#endif // export + +#if defined(extern) +#define extern EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "extern". \ +Enable warning C4005 to find the forbidden define. +#endif // extern + +#if defined(false) +#define false EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "false". \ +Enable warning C4005 to find the forbidden define. +#endif // false + +#if defined(float) +#define float EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "float". \ +Enable warning C4005 to find the forbidden define. +#endif // float + +#if defined(for) +#define for EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "for". \ +Enable warning C4005 to find the forbidden define. +#endif // for + +#if defined(friend) +#define friend EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "friend". \ +Enable warning C4005 to find the forbidden define. +#endif // friend + +#if defined(goto) +#define goto EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "goto". \ +Enable warning C4005 to find the forbidden define. +#endif // goto + +#if defined(if) +#define if EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "if". \ +Enable warning C4005 to find the forbidden define. +#endif // if + +#if defined(inline) +#define inline EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "inline". \ +Enable warning C4005 to find the forbidden define. +#endif // inline + +#if defined(int) +#define int EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "int". \ +Enable warning C4005 to find the forbidden define. +#endif // int + +#if defined(long) +#define long EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "long". \ +Enable warning C4005 to find the forbidden define. +#endif // long + +#if defined(mutable) +#define mutable EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "mutable". \ +Enable warning C4005 to find the forbidden define. +#endif // mutable + +#if defined(namespace) +#define namespace EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "namespace". \ +Enable warning C4005 to find the forbidden define. +#endif // namespace + +#if defined(new) && defined(_ENFORCE_BAN_OF_MACRO_NEW) +#define new EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "new", though macroized new is supported on this \ +implementation as a nonstandard extension. Enable warning C4005 to find the forbidden define, or re-enable the \ +extension by removing _ENFORCE_BAN_OF_MACRO_NEW. +#endif // new + +#if defined(noexcept) +#define noexcept EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "noexcept". \ +Enable warning C4005 to find the forbidden define. +#endif // noexcept + +#if defined(nullptr) +#define nullptr EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "nullptr". \ +Enable warning C4005 to find the forbidden define. +#endif // nullptr + +#if defined(operator) +#define operator EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "operator". \ +Enable warning C4005 to find the forbidden define. +#endif // operator + +#if defined(private) +#define private EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "private". \ +Enable warning C4005 to find the forbidden define. +#endif // private + +#if defined(protected) +#define protected EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "protected". \ +Enable warning C4005 to find the forbidden define. +#endif // protected + +#if defined(public) +#define public EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "public". \ +Enable warning C4005 to find the forbidden define. +#endif // public + +#if defined(register) +#define register EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "register". \ +Enable warning C4005 to find the forbidden define. +#endif // register + +#if defined(reinterpret_cast) +#define reinterpret_cast EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "reinterpret_cast". \ +Enable warning C4005 to find the forbidden define. +#endif // reinterpret_cast + +#if defined(requires) && _HAS_CXX20 +#define requires EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "requires". \ +Enable warning C4005 to find the forbidden define. +#endif // requires + +#if defined(return) +#define return EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "return". \ +Enable warning C4005 to find the forbidden define. +#endif // return + +#if defined(short) +#define short EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "short". \ +Enable warning C4005 to find the forbidden define. +#endif // short + +#if defined(signed) +#define signed EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "signed". \ +Enable warning C4005 to find the forbidden define. +#endif // signed + +#if defined(sizeof) +#define sizeof EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "sizeof". \ +Enable warning C4005 to find the forbidden define. +#endif // sizeof + +#if defined(static) +#define static EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "static". \ +Enable warning C4005 to find the forbidden define. +#endif // static + +#if defined(static_assert) +#define static_assert EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "static_assert". \ +Enable warning C4005 to find the forbidden define. +#endif // static_assert + +#if defined(static_cast) +#define static_cast EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "static_cast". \ +Enable warning C4005 to find the forbidden define. +#endif // static_cast + +#if defined(struct) +#define struct EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "struct". \ +Enable warning C4005 to find the forbidden define. +#endif // struct + +#if defined(switch) +#define switch EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "switch". \ +Enable warning C4005 to find the forbidden define. +#endif // switch + +#if defined(template) +#define template EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "template". \ +Enable warning C4005 to find the forbidden define. +#endif // template + +#if defined(this) +#define this EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "this". \ +Enable warning C4005 to find the forbidden define. +#endif // this + +#if defined(thread_local) +#define thread_local EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "thread_local". \ +Enable warning C4005 to find the forbidden define. +#endif // thread_local + +#if defined(throw) +#define throw EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "throw". \ +Enable warning C4005 to find the forbidden define. +#endif // throw + +#if defined(true) +#define true EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "true". \ +Enable warning C4005 to find the forbidden define. +#endif // true + +#if defined(try) +#define try EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "try". \ +Enable warning C4005 to find the forbidden define. +#endif // try + +#if defined(typedef) +#define typedef EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "typedef". \ +Enable warning C4005 to find the forbidden define. +#endif // typedef + +#if defined(typeid) +#define typeid EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "typeid". \ +Enable warning C4005 to find the forbidden define. +#endif // typeid + +#if defined(typename) +#define typename EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "typename". \ +Enable warning C4005 to find the forbidden define. +#endif // typename + +#if defined(union) +#define union EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "union". \ +Enable warning C4005 to find the forbidden define. +#endif // union + +#if defined(unsigned) +#define unsigned EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "unsigned". \ +Enable warning C4005 to find the forbidden define. +#endif // unsigned + +#if defined(using) +#define using EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "using". \ +Enable warning C4005 to find the forbidden define. +#endif // using + +#if defined(virtual) +#define virtual EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "virtual". \ +Enable warning C4005 to find the forbidden define. +#endif // virtual + +#if defined(void) +#define void EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "void". \ +Enable warning C4005 to find the forbidden define. +#endif // void + +#if defined(volatile) +#define volatile EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "volatile". \ +Enable warning C4005 to find the forbidden define. +#endif // volatile + +#if defined(wchar_t) +#define wchar_t EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "wchar_t". \ +Enable warning C4005 to find the forbidden define. +#endif // wchar_t + +#if defined(while) +#define while EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the keyword "while". \ +Enable warning C4005 to find the forbidden define. +#endif // while + +// contextual keywords (a.k.a. "identifiers with special meaning"): +#if defined(final) +#define final EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the contextual keyword "final". \ +Enable warning C4005 to find the forbidden define. +#endif // final + +#if defined(import) && _HAS_CXX20 +#define import EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the contextual keyword "import". \ +Enable warning C4005 to find the forbidden define. +#endif // import + +#if defined(module) && _HAS_CXX20 +#define module EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the contextual keyword "module". \ +Enable warning C4005 to find the forbidden define. +#endif // module + +#if defined(override) +#define override EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the contextual keyword "override". \ +Enable warning C4005 to find the forbidden define. +#endif // override + +// attribute-tokens: +#if defined(carries_dependency) +#define carries_dependency EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the attribute-token "carries_dependency". \ +Enable warning C4005 to find the forbidden define. +#endif // carries_dependency + +#if defined(deprecated) +#define deprecated EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the attribute-token "deprecated". \ +Enable warning C4005 to find the forbidden define. +#endif // deprecated + +#if defined(fallthrough) && _HAS_CXX17 +#define fallthrough EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the attribute-token "fallthrough". \ +Enable warning C4005 to find the forbidden define. +#endif // fallthrough + +// not checking "likely" because it is commonly defined as a function-like macro + +#if defined(maybe_unused) && _HAS_CXX17 +#define maybe_unused EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the attribute-token "maybe_unused". \ +Enable warning C4005 to find the forbidden define. +#endif // maybe_unused + +#if defined(nodiscard) // C++17 attribute-token, also enforced in C++14 mode +#define nodiscard EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the attribute-token "nodiscard". \ +Enable warning C4005 to find the forbidden define. +#endif // nodiscard + +#if defined(noreturn) +#define noreturn EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the attribute-token "noreturn". \ +Enable warning C4005 to find the forbidden define. +#endif // noreturn + +#if defined(no_unique_address) && _HAS_CXX20 +#define no_unique_address EMIT WARNING C4005 +#error The C++ Standard Library forbids macroizing the attribute-token "no_unique_address". \ +Enable warning C4005 to find the forbidden define. +#endif // no_unique_address + +// not checking "unlikely" because it is commonly defined as a function-like macro + +#endif // !defined(_ALLOW_KEYWORD_MACROS) && !defined(__INTELLISENSE__) + +#endif // _STL_COMPILER_PREPROCESSOR +#endif // _XKEYCHECK_H + +#ifndef _NODISCARD +#define _NODISCARD [[nodiscard]] +#endif // !_NODISCARD + +#pragma endregion + +#pragma region MSVC Features + +#ifndef __Non_Portable_Features + +#define __Non_Portable_Features + +//Depends on the Microsoft C++ implementation + +#ifdef _MSC_VER + +#include + +#define _allocator_ret_ __declspec(allocator) + +#else + +#define _allocator_ret_ __declspec(allocator) + +#endif // _MSC_VER + +#pragma region __TEST_MICROSOFT_IMPLEMENTATION + +#if defined(__USE__) || (defined(_DEBUG)&&0) || defined(_USE_Non_Portable_Features) + +//Variadic +//__declspec(align(#)) + +#endif // __TEST_MICROSOFT_IMPLEMENTATION + +#pragma endregion + +//----------------------------------------------- +//----------------------------------------------- +//----------------------------------------------- +//----------------------------------------------- + +#pragma region __based + +#if defined(__USE_BASE_PTR) || (defined(_DEBUG)&&0) || defined(_USE_Non_Portable_Features) + +//class +//__based +template +class BasePtr +{ +public: + typedef _T __based(_Ptr)*Offset; + _T& operator[](_In_ const size_t index) + { + Offset offset = 0; + return *(offset + index); + } +}; + +//Variadic +//__based +#define DefineBasePtr(_T,_Ptr_Name,_Ptr_Org,_P) \ + _T* _Ptr_Name = &_Ptr_Org[0]; \ + typedef _T __based(_Ptr_Name)* _P; \ + +//Variadic +//__based +#define TransfromBasePtr(_Ptr_Name,_Ptr_Org) \ + _Ptr_Name = &_Ptr_Org[0] \ + +#endif // __USE_BASE_PTR + +#pragma endregion + +#pragma region __inheritance + +#if defined(__USE_INHERITANCE) || (defined(_DEBUG)&&0) || defined(_USE_Non_Portable_Features) + +//Variadic +//__single_inheritance +#define single_inheritance __single_inheritance + +#endif // __USE_INHERITANCE + +#pragma endregion + +#pragma region alignof + +#if defined(__USE_ALIGNOF) || (defined(_DEBUG)&&0) || defined(_USE_Non_Portable_Features) + +template +class AlignInfo final +{ +public: + AlignInfo() :type(typeid(_T)), align_size(alignof(_T)), memory_size(sizeof(_T)) + { + } + + const type_info& type; + const size_t align_size; + const size_t memory_size; + + template + bool operator==(const AlignInfo<_P>& _Right) + { + return this->align_size == _Right.align_size; + } + template + bool operator!=(const AlignInfo<_P>& _Right) + { + return this->align_size != _Right.align_size; + } + template<> + bool operator==(const AlignInfo<_T>& _Right) + { + return true; + } + template<> + bool operator!=(const AlignInfo<_T>& _Right) + { + return false; + } +}; + +//Variadic +//__declspec(align(#)) +#define DeclspecAlign(size_move) __declspec(align(1< +//#include + +namespace std +{ + inline std::string to_string(const std::string& str) + { + return str; + } + inline std::wstring to_wstring(const std::wstring& str) + { + return str; + } + inline std::string to_string(const std::filesystem::path& path) + { + return path.string(); + } + inline std::wstring to_wstring(const std::filesystem::path& path) + { + return path.wstring(); + } + inline std::string to_string(const std::wstring& str) + { + return to_string(std::filesystem::path(str)); + } + inline std::wstring to_wstring(const std::string& str) + { + return to_wstring(std::filesystem::path(str)); + } + inline std::string to_string(const char* str) + { + return std::string(str); + } + inline std::wstring to_wstring(const wchar_t* str) + { + return std::wstring(str); + } + template + inline std::string to_string(const char str[size]) + { + return std::string(str); + } + template + inline std::wstring to_wstring(const wchar_t str[size]) + { + return std::wstring(str); + } +} + +struct CharIndicator +{ +#if defined(UNICODE) + using tag = wchar_t; + static constexpr bool value = true; +#else + using tag = char; + static constexpr bool value = false; +#endif // _UNICODE +}; +struct StringIndicator +{ + using tag = std::basic_string; + static constexpr bool value = CharIndicator::value; + + using traits = std::char_traits; + + static size_t strlen(const CharIndicator::tag* str) + { + return traits::length(str); + } + static CharIndicator::tag* strcpy( + CharIndicator::tag* dest, + const CharIndicator::tag* source + ) + { + return traits::copy(dest, source, strlen(source)); + } + static CharIndicator::tag* strcpy_s( + CharIndicator::tag* dest, + const CharIndicator::tag* source, + const size_t size + ) + { + return traits::copy(dest, source, std::min(size, strlen(source))); + } + + static size_t c_strlen(const char* str) + { + return ::strlen(str); + } + static char* c_strcpy( + char* dest, + const char* source + ) + { + return ::strcpy(dest, source); + } + static int c_strcpy_s( + char* dest, + const char* source, + const size_t size + ) + { + return ::strcpy_s(dest, std::min(size, c_strlen(source)), source); + } + + template + static str ToString(const T& value) + { + if_exists(T::ToString) + return value.ToString(); + if constexpr (std::is_constructible_v) + return value; + else if constexpr (std::is_same_v) + return std::to_wstring(value); + else + return std::to_string(value); + } + template + static T ToValue(const str& value) + { + if constexpr (std::is_floating_point_v) + return std::stold(value); + else if constexpr (std::is_integral_v && std::is_unsigned_v == false) + return std::stoll(value); + else if constexpr (std::is_integral_v && std::is_unsigned_v == true) + return std::stoull(value); + else if constexpr (std::is_same_v) + { + auto temp = std::to_string(value); + if (temp == "false") + return false; + else if (temp == "true") + return true; + else + throw std::runtime_error("Cannot convert string to bool. Expected 'true' or 'false'."); + } + else if constexpr (std::is_same_v || std::is_same_v) + { + if (value.count() != 1) + throw std::runtime_error("Cannot convert string to char. Expected a single character."); + static_assert(sizeof(T) < sizeof(decltype(value.front())), "Cannot convert string to a smaller character"); + return value.front(); + } + else if constexpr (std::is_convertible_v) + return static_cast(value); + else + static_assert(std::is_convertible_v, "Cannot convert string to the specified type."); + } + + template + static str Combine(const _T& first) + { + return ToString(first); + } + template + static str Combine(const _First& first, const _LeftT& arg) + { + return ToString(first) + ToString(arg); + } + template + static str Combine(const _First& first, const Args&...args) + { + return ToString(first) + Combine(args...); + } + + // trim whitespace from the beginning and end of a string + template + str Trim(const str& input, const str& chs, bool isLeft = true, bool isRight = true) + { + size_t start = 0; + size_t end = input.size(); + + if (isLeft) + { + bool stats = true; + while (start < end && stats) + { + stats = false; + for (auto&& ch : chs) + { + if (ch == input[start]) + { + start++; + stats = true; + break; + } + } + } + } + if (isRight) + { + bool stats = true; + while (start < end && stats) + { + stats = false; + for (auto&& ch : chs) + { + if (ch == input[end-1]) + { + end--; + stats = true; + break; + } + } + } + } + return input.substr(start, end - start); + } + + /** + * brief Formats a string using the provided format and arguments. like use snprintf + */ + template + static str Format(size_t size, const std::string& format, const Args&... args) + { + str result; + result.reserve(size); + snprintf(result.data(), size, format.c_str(), args...); + return result; + } +}; + +#ifdef UNICODE +#define COUT std::wcout +#define __CNTEXT(str) L##str +#define CNTEXT(str) __CNTEXT(str) +#else +#define COUT std::cout +#define __CNTEXT(str) u8##str +#define CNTEXT(str) __CNTEXT(str) +#endif +#define make_string(str) StringIndicator::tag(CNTEXT(str)) + +#pragma endregion + +#pragma region Kit + +#ifndef __init +#define __init(member) member(member) +#endif // !__init + +#pragma endregion + +#pragma region Kit + +#if _HAS_CXX20 +#define is_constant_env() std::is_constant_evaluated() +#else +constexpr bool is_constant_env() +{ + return false; +} +#endif + +constexpr bool is_clang_env() +{ +#ifdef __clang__ + return true; +#else + return false; +#endif // __clang__ +} + +#pragma endregion + +#pragma region Kit + +namespace Convention +{ + template + void Construct(_In_ T* ptr, Args&&... args) + { + new(ptr) T(std::forward(args)...); + } + template + void Destruct(_In_ T* ptr) + { + ptr->~T(); + } +} + +#pragma endregion + +template +_Notnull_ _T* no_warning_6387(_In_opt_ _T* from) +{ + if (from == nullptr) + { + throw std::bad_alloc(); + } + return from; +} + +namespace Convention +{ + // first module name will in pair: "execute":path + // other key will remove front '-' charactor + // if a string that is not prefixed with the character '-' does not follow a key, it becomes a key + class CommandLineReader + { + public: + std::map KeyValuePair; + std::vector> KeyVector; + CommandLineReader(int argc, char** argv) + { + std::map& first = KeyValuePair; + std::vector>& second = KeyVector; + std::string key; + std::string value; + bool isKey = true; + if (argc > 0) + { + first["execute"] = argv[0]; + second.push_back({ argv[0],"" }); + } + for (int i = 1; i < argc; i++) + { + if (second.size() != 0 && + second.back().first.front() == '-' && + second.back().second.size() == 0 && + argv[i][0] != '-' + ) + second.back().second = argv[i]; + else + second.push_back({ argv[i],"" }); + + if (argv[i][0] == '-') + { + if (isKey) + key = argv[i]; + else + first[key] = value; + isKey = false; + key = argv[i]; + while (key.front() == '-') + { + key.erase(key.begin()); + if (key.size() == 0) + { + isKey = true; + break; + } + } + } + else if (isKey == false) + { + first[key] = argv[i]; + isKey = true; + } + else + { + first[argv[i]] = ""; + isKey = true; + } + } + if (isKey == false) + { + first[key] = ""; + second.push_back({ key,"" }); + } + } + }; + + template + struct DescriptiveIndicator + { + using tag = _Type; + constexpr static bool value = true; + const char* description; + tag target; + DescriptiveIndicator(const char* description, tag target) noexcept : + __init(description), __init(target) { + } + }; + template<> + struct DescriptiveIndicator + { + using tag = void; + constexpr static bool value = false; + const char* description; + DescriptiveIndicator(const char* description) noexcept : + __init(description) { + } + }; + +#pragma region is_specialization + + // 基础模板 + template class Template> + struct is_specialization : std::false_type {}; + + // 特化模板 + template class Template, typename... Args> + struct is_specialization, Template> : std::true_type + { + using tags = std::tuple; + }; + +#pragma endregion + +} + +#pragma region __PRETTY_FUNCTION__ + +#if !defined(__PRETTY_FUNCTION__) && !defined(__GNUC__) +#define __PRETTY_FUNCTION__ __FUNCSIG__ +#endif + +#define PrettyFunctionName() __PRETTY_FUNCTION__ + +#pragma endregion + +#pragma region Tree + +namespace Convention +{ + template + class ElementTuple + { + private: + using _MySelf = ElementTuple; + using _MyNext = ElementTuple; + public: + constexpr static size_t size = sizeof(Element) + _MyNext::size; + constexpr static size_t _MySize = 1 + _MyNext::_MySize; + private: + char elements[size]; + public: + template + using ElementType = std::conditional_t>; + template + constexpr static size_t ElementOffset() + { + static_assert(index < _MySize, "Index out of bounds for ElementTuple."); + if constexpr (index == 0) + return sizeof(Element); + else + return sizeof(Element) + _MyNext::ElementOffset(); + } + template + decltype(auto) GetValue() const noexcept + { + static_assert(index < _MySize, "Index out of bounds for ElementTuple."); + return *reinterpret_cast*>(&elements[ElementOffset()]); + } + template + decltype(auto) GetValue() noexcept + { + static_assert(index < _MySize, "Index out of bounds for ElementTuple."); + return *reinterpret_cast*>(&elements[ElementOffset()]); + } + template())>>, size_t> = 0> + void SetValue(Arg&& value) noexcept + { + GetValue() = std::forward(value); + } + template())>>, size_t> = 0> + void SetValue(const Arg& value) noexcept + { + GetValue() = value; + } + }; + template + class ElementTuple + { + public: + constexpr static size_t size = sizeof(Element); + constexpr static size_t _MySize = 1; + private: + Element elements; + public: + template + using ElementType = std::enable_if_t; + template + constexpr static size_t ElementOffset() + { + static_assert(index == 0, "Index out of bounds for ElementTuple."); + return sizeof(Element); + } + template + constexpr const Element& GetValue() const noexcept + { + static_assert(index == 0, "Index out of bounds for ElementTuple."); + return elements; + } + template + constexpr Element& GetValue() noexcept + { + static_assert(index == 0, "Index out of bounds for ElementTuple."); + return elements; + } + template, size_t> = 0> + void SetValue(Arg&& value) noexcept + { + static_assert(index == 0, "Index out of bounds for ElementTuple."); + elements = std::forward(value); + } + template>, size_t> = 0 > + void SetValue(const Arg & value) noexcept + { + static_assert(index == 0, "Index out of bounds for ElementTuple."); + GetValue() = value; + } + }; + template + class ElementTuple : public ElementTuple {}; + template<> + class ElementTuple + { + public: + constexpr static size_t size = 0; + constexpr static size_t _MySize = 0; + }; +} + +#pragma endregion + +#endif // !CONVENTION_KIT_CONFIG_H diff --git a/Convention/src/CMakeLists.txt b/Convention/src/CMakeLists.txt new file mode 100644 index 0000000..9ae9e02 --- /dev/null +++ b/Convention/src/CMakeLists.txt @@ -0,0 +1,85 @@ +aux_source_directory(./src cpps) + +# 创建库 +add_library(Convention-Static STATIC ${cpps}) +add_library(Convention-Shared SHARED ${cpps}) + +# 设置别名,使得在本项目中可以使用命名空间版本 +add_library(Convention::Static ALIAS Convention-Static) +add_library(Convention::Shared ALIAS Convention-Shared) + +# 为库设置属性 +set_target_properties(Convention-Static PROPERTIES + OUTPUT_NAME "Convention-Static" + EXPORT_NAME "Static" + POSITION_INDEPENDENT_CODE ON +) + +set_target_properties(Convention-Shared PROPERTIES + OUTPUT_NAME "Convention-Shared" + EXPORT_NAME "Shared" + POSITION_INDEPENDENT_CODE ON + WINDOWS_EXPORT_ALL_SYMBOLS ON + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Convention" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Convention" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Convention" +) + +# 设置包含目录 +target_include_directories(Convention-Static PUBLIC + $ + $ +) + +target_include_directories(Convention-Shared PUBLIC + $ + $ +) + +# 安装头文件 +install(FILES ${Root_Headers} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Convention) + +# 安装库文件并生成导出目标 +install(TARGETS Convention-Static + EXPORT ConventionTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(TARGETS Convention-Shared + EXPORT ConventionTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +# 安装导出目标文件 +install(EXPORT ConventionTargets + FILE ConventionTargets.cmake + NAMESPACE Convention:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Convention) + +# 生成配置文件 +include(CMakePackageConfigHelpers) + +# 生成版本文件 +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/ConventionConfigVersion.cmake" + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion +) + +# 配置并安装Config文件 +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ConventionConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/ConventionConfig.cmake + @ONLY +) + +# 安装配置文件 +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/ConventionConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/ConventionConfigVersion.cmake" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Convention +) + +message("Convention: ----- ----- ----- ----- -----") \ No newline at end of file